刚学 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')),
)‘
1
Changxu 2015-12-03 13:54:14 +08:00
from views import first_page
.... url(r'^$', first_page), .... 文档那个英文句子的意思是 1.10 里 url 的视图路径不能用字符串字面值(string literal)了 |
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 |