I am currently trying out Django. I use the namespace
argument in one of my include()
s in urls.py. When I run the server and try to browse,
I get this error.
File "C:UsersUserAppDataLocalProgramsPythonPython36-32libsite-packagesdjangourlsconf.py", line 39, in include
'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
These are my urls.py files:
#project/urls.py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^reviews/', include('reviews.urls', namespace='reviews')),
url(r'^admin/', include(admin.site.urls)),
]
and
#app/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
# ex: /
url(r'^$', views.review_list, name='review_list'),
# ex: /review/5/
url(r'^review/(?P<review_id>[0-9]+)/$', views.review_detail, name='review_detail'),
# ex: /wine/
url(r'^wine$', views.wine_list, name='wine_list'),
# ex: /wine/5/
url(r'^wine/(?P<wine_id>[0-9]+)/$', views.wine_detail, name='wine_detail'),
]
What do I pass the app_name
as stated in the error message?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…