Opened 11 years ago
Last modified 11 years ago
#20645 closed Uncategorized
reverse URL broken when you use includes — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
if you use an include in your base URLConf and then use a name= in that subsequent URLConf, the name doesn't resolve when you do a reverse match in the url tag in a template.
Example:
Root
url.py
urlpatterns = patterns(,
url(r'bar/', include('bar.urls')),
)
Bar
url.py
urlpatterns = patterns('bar.views',
url(r'makeFoo/$', foo, name="generateFoo"),
)
in a HTML Template
{% url "generateFoo" %}
This generates a NoReverseMatch
If you put that named url in the root url patterns, the Reverse will find it and render it normally.