#15658 closed Bug (invalid)
reverse returns '//' for flatpage with URL '/'
Reported by: | Fladi | Owned by: | Andy Durdin |
---|---|---|---|
Component: | contrib.flatpages | Version: | 1.2 |
Severity: | Normal | Keywords: | flatpages |
Cc: | me@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using reverse() with a flatpage url '/'
results in '//'
.
urlpatterns = patterns('', (r'^', include('django.contrib.flatpages.urls')), )
>>> from django.core.urlresolvers import reverse; reverse('django.contrib.flatpages.views.flatpage', kwargs={'url': '/'}) '//'
settings.APPEND_SLASH is False but should not affect this anyways.
Change History (7)
comment:1 by , 14 years ago
Component: | Uncategorized → Contrib apps |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Component: | Contrib apps → contrib.flatpages |
---|
comment:3 by , 14 years ago
Type: | → Bug |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|
comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:6 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
Invalid.
The initial '/' in the path is matched by the root urlresolver, and so is not included in the kwargs of the resolved view nor should it be included in the kwargs when reversing. For example, when '/' resolves to flatpage.views.flatpage, the view is called with the kwarg url=''
. Similarly, reverse('django.contrib.flatpages.views.flatpage', kwargs={'url': ''})
returns '/'. This is correct and expected behaviour.
You should be calling reverse() with kwargs={'url': ''}
.
comment:7 by , 13 years ago
Cc: | added |
---|
I can confirm this is a real issue.
Btw, this issue is the reason why most CMS applications use two URLconf entries for reversing; in the case of FeinCMS feincms_home (r'$') and feincms_handler (r'(.*)/$')