python – Django的AUTH_PROFILE_MODULE更改登录成功网址?

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

所以我这样做是为我的自定义MyUser模型创建MyUserProfile模型.
一切正常,除了登录时(localhost / accounts / login),url被重定向到htp:// localhost:9999 / accounts / profile而不是我在表单隐藏输入中指定的索引页面.

这个重定向网址在哪里定义.. ??

最佳答案
使用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.

相关文章

我最近重新拾起了计算机视觉,借助Python的opencv还有face_r...
说到Pooling,相信学习过CNN的朋友们都不会感到陌生。Poolin...
记得大一学Python的时候,有一个题目是判断一个数是否是复数...
文章目录 3 直方图Histogramplot1. 基本直方图的绘制 Basic ...
文章目录 5 小提琴图Violinplot1. 基础小提琴图绘制 Basic v...
文章目录 4 核密度图Densityplot1. 基础核密度图绘制 Basic ...