菜鸟问个初学 Django 的问题 RemovedInDjango110Warning - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Banio
V2EX    Python

菜鸟问个初学 Django 的问题 RemovedInDjango110Warning

  •  
  •   Banio 2015 年 12 月 3 日 8098 次点击
    这是一个创建于 3724 天前的主题,其中的信息可能已经有所发展或是发生改变。

    刚学 Django 安装 http://www.cnblogs.com/vamei/p/3531740.html 这篇文章里操作的
    我执行完$python manage.py migrate 之后 终端这样显示

    vagrant@Vbox-5-0-6:~/mysite$ python manage.py migrate
    /usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning: /home/vagrant/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
    warnings.warn(msg, UserWarning)

    /home/vagrant/mysite/mysite/urls.py:36: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got mysite.views.first_page). Pass the callable instead.
    url(r'^$', 'mysite.views.first_page'),

    /home/vagrant/mysite/west/urls.py:4: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got west.views.first_page). Pass the callable instead.
    url(r'^$', 'west.views.first_page'),

    /home/vagrant/mysite/west/urls.py:4: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
    url(r'^$', 'west.views.first_page'),

    /home/vagrant/mysite/mysite/urls.py:37: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
    url(r'^west/', include('west.urls')),

    Operations to perform:
    Apply all migrations: admin, contenttypes, auth, sessions
    Running migrations:
    Rendering model states... DONE
    Applying contenttypes.0001_initial... OK
    Applying auth.0001_initial... OK
    Applying admin.0001_initial... OK
    Applying admin.0002_logentry_remove_auto_add... OK
    Applying contenttypes.0002_remove_content_type_name... OK
    Applying auth.0002_alter_permission_name_max_length... OK
    Applying auth.0003_alter_user_email_max_length... OK
    Applying auth.0004_alter_user_username_opts... OK
    Applying auth.0005_alter_user_last_login_null... OK
    Applying auth.0006_require_contenttypes_0002... OK
    Applying auth.0007_alter_validators_add_error_messages... OK
    Applying sessions.0001_initial... OK

    我看字面意思是 我这种 url()写法在 Django 1.10 中不支持了 而且会被移除
    那请问 正确的写法是什么 谢谢
    urls.py 我这里这样写的
    ‘ from django.conf.urls import patterns, include, url

    from django.contrib import admin
    admin.autodiscover()

    urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', 'mysite.views.first_page'),
    url(r'^west/', include('west.urls')),
    )‘

    3 条回复    2015-12-07 08:39:33 +08:00
    Changxu
        1
    Changxu  
       2015 年 12 月 3 日
    from views import first_page

    ....
    url(r'^$', first_page),
    ....

    文档那个英文句子的意思是 1.10 里 url 的视图路径不能用字符串字面值(string literal)了
    lenciel
        2
    lenciel  
       2015 年 12 月 3 日
    1. 你在用没有正式 release 的 django 版本,这样不好(最新的 stable 的版本应该是 1.9 )
    2. 遇到`RemovedInDjango110Warning`这种错,你都可以查文档,比如`url()`的最新版本的文档:
    http://django.readthedocs.org/en/latest/ref/urls.html#url
    Banio
        3
    Banio  
    OP
       2015 年 12 月 7 日
    @lenciel 谢谢 我用的是 1.9 版本的 Django 我看看文档
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2418 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 44ms UTC 12:26 PVG 20:26 LAX 04:26 JFK 07:26
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86