Friday, August 1, 2014

Re: Using settings.LOGIN_URL and django.core.urlresolvers.reverse

Have you tried using reverse_lazy instead of reverse?

On Wednesday, April 25, 2007 12:32:16 PM UTC+2, Matt wrote:
Hi everyone,

I have a quick question about the new LOGIN_URL, LOGOUT_URL, and
LOGIN_REDIRECT_URL settings.  If, in my project's settings module, I
write:

    LOGIN_URL = '/blah/'
    LOGOUT_URL = '/blah/blah/'
    LOGIN_REDIRECT_URL = '/blah/blah/blah/'

They work just fine.  But I want to remove hard-coded URLs from my
code; so I write:

    from django.core.urlresolvers import reverse
    LOGIN_URL = reverse('django.contrib.auth.views.login')
    LOGOUT_URL = reverse('django.contrib.auth.views.logout')
    LOGIN_REDIRECT_URL = reverse('gigall.apps.accounts.views.profile')

This fails; the URLs used are Django's defaults.

Does anyone know why this is so?  And can I work around it?

Cheers,
M.

--
Matt Riggott (mailto:matt.r...@gmail.com).
Dictated but not read.

--
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/f3c500d7-1312-4c09-b8b7-c33ce43d9060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment