gpt4 book ai didi

python - 无法登录我在 django 中创建的用户帐户

转载 作者:行者123 更新时间:2023-11-29 22:02:20 24 4
gpt4 key购买 nike

我可以使用 super 用户登录我的网站,但我创建的帐户获得无效的登录页面。我使用的是 django 身份验证系统,而不是我自己的。

在发生这种情况之前,我犯了一个错误,删除了模型之一中的一个字段来修复某些问题(不知道为什么我认为这会有所帮助)。我刷新了数据库并再次添加了该字段来解决这个问题。

刷新后,当我尝试迁移有重复列时出现错误。运行 python manage.py migrate --fake 解决了这个问题。

我创建了一些新用户来在管理站点中进行测试,但是当我尝试使用它们登录时,它不起作用。

有什么想法吗?

我改变的模型

class Ticket(models.Model):
title = models.CharField(max_length=144)
user = models.ForeignKey(User)
message = models.TextField()
catagoryID = models.ForeignKey(Catagory)
priority = models.PositiveSmallIntegerField()
userEmail = models.EmailField(max_length=100)
resolved = models.BooleanField(default = False)
dateOfIssue = models.DateField(auto_now_add=True)

我删除的字段是用户字段。如果有必要,我会发布更多代码。

最佳答案

不确定这是否对您有帮助,但请检查创建的用户是否处于事件状态。也可能是 cookie 未正确设置的问题,如 django documentation 中所述。

The login cookie isn’t being set correctly, because the domain of the cookie sent out by Django doesn’t match the domain in your browser. Try these two things:

Set the SESSION_COOKIE_DOMAIN setting in your admin config file to match your domain. For example, if you’re going to “http://www.example.com/admin/” in your browser, in “myproject.settings” you should set SESSION_COOKIE_DOMAIN = ‘www.example.com’.

关于python - 无法登录我在 django 中创建的用户帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32505978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com