Opened 17 years ago

Closed 17 years ago

#4129 closed (fixed)

Named urls break view prefix.

Reported by: justin.driscoll@… 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)

5079-patch_for_url_and_prefix.diff (2.0 KB ) - added by Michael Axiak <axiak@…> 17 years ago.
My crack at a fix for this bug.
5079-patch_for_url_and_prefix_2.diff (2.0 KB ) - added by Michael Axiak <axiak@…> 17 years ago.
I had a typo.

Download all attachments as: .zip

Change History (11)

comment:1 by Malcolm Tredinnick, 17 years ago

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?

in reply to:  1 comment:2 by anonymous, 17 years ago

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 by Gary Wilson <gary.wilson@…>, 17 years ago

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 by justin.driscoll@…, 17 years ago

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 by Gary Wilson <gary.wilson@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

You might want to start a discussing about it on the django-dev mailing list.

comment:6 by Malcolm Tredinnick, 17 years ago

Triage Stage: Design decision neededAccepted

This is just a bug. No discussion required.

by Michael Axiak <axiak@…>, 17 years ago

My crack at a fix for this bug.

by Michael Axiak <axiak@…>, 17 years ago

I had a typo.

comment:7 by Michael Axiak <axiak@…>, 17 years ago

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.

in reply to:  7 comment:8 by Malcolm Tredinnick, 17 years ago

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 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [5086]) Fixed #4129 -- Pass any prefix setting into url(...) constructions so that
prefixes work with the new syntax and strings for function names.

Note: See TracTickets for help on using tickets.
Back to Top