How do I reference Django 1.5 URLs that are "named" in an included URL file? -
i have project's main urls.py file following:
url(r'^accounts/$', include('accounts.urls'),
in accounts.urls.py, have following:
urlpatterns = patterns('accounts.views', url(r'^profile/$', 'accounts_profile', name='accounts_profile'),
in base.html template, have:
<li><a href="{% url 'accounts_profile' %}">profile</a></li>
this results in reversenotfound error:
noreversematch @ / reverse 'accounts_profile' arguments '()' , keyword arguments '{}' not found.
if move accounts_profile url definition main urls.py, url works. remember style of url organization working in prior django version; has changed, or doing wrong?
get rid of $ in url(r'^accounts/$', include('accounts.urls'),
call.
note regular expressions in example don’t have $ (end-of-string match character) include trailing slash.
https://docs.djangoproject.com/en/dev/topics/http/urls/#including-other-urlconfs
Comments
Post a Comment