Django 1.10 no longer allows you to specify views as a string (e.g. ‘myapp.views.home‘) in your URL patterns.
The solution is to update your urls.py to include the view callable. This means that you have to import the view in your urls.py. If your URL patterns don‘t have names, then now is a good time to add one, because reversing with the dotted python path no longer works.
from django.contrib.auth.views import loginfrom myapp.views import home, contacturlpatterns = [ ???url(r‘^$‘, home, name=‘home‘), ???url(r‘^contact/$‘, contact, name=‘contact‘), ???url(r‘^login/$‘, login, name=‘login‘),]
If there are many views, then importing them individually can be inconvenient. An alternative is to import the views module from your app.
from django.contrib.auth import views as auth_viewsfrom myapp import views as myapp_viewsurlpatterns = [ ???url(r‘^$‘, myapp_views.home, name=‘home‘), ???url(r‘^contact/$‘, myapp_views.contact, name=‘contact‘), ???url(r‘^login/$‘, auth_views.login, name=‘login‘),]Note that we have used as myapp_views and as auth_views, which allows us to import the views.py from multiple apps without them clashing.
See the Django URL dispatcher docs for more information about urlpatterns.
Django URLs error: view must be a callable or a list/tuple in the case of include()
原文地址:http://www.cnblogs.com/klsw/p/7788068.html