加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-16 21:49:15 所属栏目:Python 来源:网络整理
导读: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:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读