Hmm, well after looking at the source of the `reverse` method I can see
that it's not doing what I imagined it was...
I am so used to always naming my urls in urlconfs, when I saw a full import
path to a view function like:
reverse('django.contrib.auth.views.password_reset_done')
in the auth/views.py I assumed it ought to find that vew function in
whichever urlconf it was defined
Thinking about it, it can't do that because you could easily have more than
one url pointing to that function
It means if you have something like this in your root urlconf:
(r'^accounts/', include('django.contrib.auth.urls', namespace="auth")),
then the reverse isn't going to work because it would have to be:
reverse('auth:django.contrib.auth.views.password_reset_done')
in short, don't use a namespace on the built-in auth urls
Arguably, the auth views could work out what namespace they're under and
handle it though, eg:
(django/contrib/auth/views.py #147)
resolver = resolve(request.path)
ns = ''
if resolver.namespace:
ns = resolver.namespace + ':'
post_reset_redirect =
reverse('{0}django.contrib.auth.views.password_reset_done'.format(ns))
(admittedly this assumes you have imported all of the auth urls into the
same namespace)
On Monday, 19 August 2013 12:27:57 UTC+1, anentropic wrote:
>
> This seems a bug in Django... the `reverse` function is passed the name of
> a view function, not a named url, so the fact that the url it's being asked
> to match is included under a namespace shouldn't matter?
>
> (here because I just hit the same problem myself)
>
> On Saturday, 27 July 2013 08:20:18 UTC+1, Peter wrote:
>>
>> Yep, that fixed it. Thanks.
>>
>> I still think it's wrong of django not to find it by view name though...
>>
>>
>>> Probably because you've included it under a namespace, so Django would
>>> need to look for it as "registration:whatever". There's no need to use the
>>> namespace in the include call.
>>> --
>>> DR.
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.