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-03 13:49:31 +08:00 · 7340 次点击
    这是一个创建于 3073 天前的主题,其中的信息可能已经有所发展或是发生改变。

    刚学 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-03 13:54:14 +08:00
    from views import first_page

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

    文档那个英文句子的意思是 1.10 里 url 的视图路径不能用字符串字面值(string literal)了
    lenciel
        2
    lenciel  
       2015-12-03 23:08:03 +08:00
    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-07 08:39:33 +08:00
    @lenciel 谢谢 我用的是 1.9 版本的 Django 我看看文档
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2206 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:13 · PVG 19:13 · LAX 04:13 · JFK 07:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.