On Jul 14, 2017 4:12 AM, "Polina Ia" <[email protected]> wrote:
Hello,
can someone explain me the setting 'redirect_field_name' in LoginView?
I have following in my urls.py:
url('^login/$', LoginView.as_view(template_name='accounts/login.html')
Now it is redirected by default to 'next'=/accounts/profile/. I'd like to
set my own url for redirect. Is it better to set 'next' value in view? Or
'redirect_field_name' in urls?
I doubt 'redirect_field_name' is what you want to change. It refers to the
hidden field name within the HTML form that contains the URL that will be
used for the successful redirect, not the URL itself.
What you are probably looking for is the 'success_url', which controls
where a request is redirected on the view side.
You can set this in urls.py if you are using the generic auth
views/classes. You can also set it as a class variable if you are
overriding those views. Alternatively, you can also override
get_success_url() in your view class.
-James
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVJj9ooX5Ri%3D4yCTEcp7TNsAY6dOagHuxTuu4Udfg65qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.