Tuesday, October 8, 2013

Re: Ho can I reverse urls inside urls.py?

On Tue, Oct 8, 2013 at 4:11 PM, DJ-Tom <eventellis@gmail.com> wrote:
> Based on this article I implemented a password reset function.
>
> Unfortunately, currently this only works on the development server because
> the base URLs for the post_reset_redirect are different on the production
> server.
>
> This is the relevant part of my urls.py, I marked the prolematic parts in
> red:
>
>
> url(r'^password/reset/$','django.contrib.auth.views.password_reset',{'post_reset_redirect'
> : '/accounts/password/reset/done/', 'template_name':
> 'accounts/password_reset.html'}, name="password_reset"),\
>
> (r'^password/reset/done/$','django.contrib.auth.views.password_reset_done',{'template_name':
> 'accounts/password_reset_done.html'}), \
>
> (r'^password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm',{'post_reset_redirect'
> : '/accounts/password/done/', 'template_name':
> 'accounts/password_reset_confirm.html'}),\
> (r'^password/done/$',
> 'django.contrib.auth.views.password_reset_complete',{'template_name':
> 'accounts/password_reset_complete.html'}),
> )
>
> Normally I would use
> reverse('django.contrib.auth.views.password_reset_done') to get the correct
> URL, but using reverse() inside the urls.py leads to a configuration error,
> so how can I put the correct URLs here so it works correct both in
> development and production?
>
> Thanks
> Thomas
>

Use reverse_lazy

https://docs.djangoproject.com/en/1.5/ref/urlresolvers/#reverse-lazy


Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAFHbX1LNXwxyi9pSfjU%2BmJ1%2Bhfyo52bzgzWeRYkZ042_NVN7sA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate