Hi all, I'm new to django and I am using django 1.6 on my local machine yet
the version of django on the company server is 1.5.4 thus I get the
following error:
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments
'()' and keyword arguments '{u'uidb64': u'4', u'token':
u'3ob-9370053c94189ea07a08'}' not found.
The error occurs when it tries to perform the following line:
{{ protocol }}://{{ domain }}{% url
'django.contrib.auth.views.password_reset_confirm' uidb64=uid token=token %}
my guess is that there is a change from django 1.5 to 1.6 in how the reverse
url is matched. How would I then change the code so that it works with the
older version(1.5), could it be the fact the uidb64 was introduced in 1.6 while
1.5 uses uidb36. Would that be the only change needed?
On Monday, August 19, 2013 1:48:24 PM UTC+2, anentropic wrote:
>
> 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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/9722be69-420d-41b3-b254-fac5b45f5ee4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.