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..??
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With