ai didi

python - Django 的 AUTH_PROFILE_MODULE 更改登录成功 url?

转载 作者:行者123 更新时间:2023-12-04 19:08:41 24 4
gpt4 key购买 nike

设置.py

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

模型.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>

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

这个重定向 url 在哪里定义..??

最佳答案

使用 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 - Django 的 AUTH_PROFILE_MODULE 更改登录成功 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18009090/

24 4 0
文章推荐: 没有键路径的数组的 Restkit 映射
文章推荐: sql - 嵌套集模型 : Inserting Node at the end of SubNodes
文章推荐: Emacs Org-Mode TODO 列表缺失项
文章推荐: prolog - 学校安排(受限逻辑)
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com