11👍
✅
You’re missing the empty string at the start of your patterns
in lists urls.py
.
Try this:
urlpatterns = patterns('',
url(r'^$', views.index, name='index')
)
The blank string is a view prefix that you can use to assist with the DRY principal. It is used to prefix your views path.
For example, (extending your example above):
Rather than having:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^homepage$', views.homepage, name='index'),
url(r'^lists$', views.lists, name='index'),
url(r'^detail$', views.detail, name='index'),
)
You can use:
urlpatterns = patterns('views',
url(r'^$', index, name='index'),
url(r'^homepage$', homepage, name='index'),
url(r'^lists$', lists, name='index'),
url(r'^detail$', detail, name='index'),
)
To have multiple view prefixes just segment your urlpatterns
.
urlpatterns = patterns('views',
url(r'^$', index, name='index'),
url(r'^homepage$', homepage, name='index'),
url(r'^lists$', lists, name='index'),
url(r'^detail$', detail, name='index'),
)
urlpatterns += patterns('more_views',
url(r'^extra_page$', extra_page, name='index'),
url(r'^more_stuff$', something_else, name='index'),
)
👤Ewan
Source:stackexchange.com