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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -