Opened 16 years ago
Closed 16 years ago
#4129 closed (fixed)
Named urls break view prefix.
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | named, urls, view, prefix | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
The following code results in a ViewDoesNotExist exception for 'archive_index' (assuming "info_dict" contains the needed parameters):
urlpatterns = patterns('django.views.generic.date_based', url(r'^articles/?$', 'archive_index', info_dict, name="article-archive-index") )
This works fine:
urlpatterns = patterns('', url(r'^articles/?$', 'django.views.generic.date_based.archive_index', info_dict, name="article-archive-index") )
View prefixes do not seem to work for custom views either when used in conjunction with named urls.
Attachments (2)
Change History (11)
comment:1 follow-up: 2 Changed 16 years ago by
comment:2 Changed 16 years ago by
Replying to mtredinnick:
What do you have to do to cause this error? You explain what error is raised, but what are you doing when it is raised -- using reverse()? Doing a normal url lookup? Other?
The error is raised when accessing the URL normally. I have not tested doing a reverse lookup as the primary functionality seems to be broken.
comment:3 Changed 16 years ago by
You will see this error if you try performing a normal URL lookup by browsing to .../articles/
since the prefix parameter from the patterns()
call doesn't get passed along to the the url()
call. The prefix only gets passed along when using url conf tuples.
comment:4 Changed 16 years ago by
Is that the intended functionality that url prefixes and named urls are incompatible? If so, it should be reflected in the documentation. Right now the docs show the url prefix empty but make no mention of it not working with the url() function. I haven't looked at the source yet, and do not know the complexity involved, but I would like to see the two play nicely together.
comment:5 Changed 16 years ago by
Triage Stage: | Unreviewed → Design decision needed |
---|
You might want to start a discussing about it on the django-dev mailing list.
comment:6 Changed 16 years ago by
Triage Stage: | Design decision needed → Accepted |
---|
This is just a bug. No discussion required.
Changed 16 years ago by
Attachment: | 5079-patch_for_url_and_prefix.diff added |
---|
My crack at a fix for this bug.
comment:7 follow-up: 8 Changed 16 years ago by
Has patch: | set |
---|---|
Patch needs improvement: | set |
Added a patch that will probably fix the bug. Setting the 'Patch needs improvement' flag until someone deems it a good patch.
comment:8 Changed 16 years ago by
Replying to Michael Axiak <axiak@mit.edu>:
Added a patch that will probably fix the bug. Setting the 'Patch needs improvement' flag until someone deems it a good patch.
Your patch would have fixed the problem. It looks fine.
In the end, I've fixed this in a very slightly different fashion so that the internal _callable_str
variable doesn't leak out of the !RegexURLPattern class. But thanks for the patch anyway.
comment:9 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
What do you have to do to cause this error? You explain what error is raised, but what are you doing when it is raised -- using reverse()? Doing a normal url lookup? Other?