Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django's AUTH_PROFILE_MODULE changing the login success url?

settings.py

AUTH_USER_MODEL = "app_registration.MyUser"
AUTH_PROFILE_MODULE = 'app_registration.MyUserProfile'

models.py

class MyUserProfile(models.Model):
    user = models.ForeignKey(MyUser, unique=True)
    ...
    MyUser.profile = property(lambda u: MyUserProfile.objects.get_or_create(user=u)[0])

login.html

<form id="login_form" method="post" action=".">
....
<input type="hidden" name="next" value="" />
<input type="submit" value="LogIn" />
</form>

So I've done this to create MyUserProfile model for my custom MyUser model. Everything works fine, except for that when I login(localhost/accounts/login), the url is redirected to htp://localhost:9999/accounts/profile instead of the index page as I specified in the form's hidden input.

Where is this redirect url defined..??

like image 322
user2492270 Avatar asked Aug 02 '13 05:08

user2492270


1 Answers

Use LOGIN_REDIRECT_URL:

LOGIN_REDIRECT_URL

Default: '/accounts/profile/'

The URL where requests are redirected after login when the contrib.auth.login view gets no next parameter.

This is used by the login_required() decorator, for example.

like image 156
falsetru Avatar answered Oct 04 '22 03:10

falsetru