无法登录我在 Django 中创建的用户帐户
Unable to login user accounts I have created in django
我可以使用超级用户登录我的站点,但我创建的帐户获得的登录页面无效。我使用的是 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)
我删除的字段是用户字段。
如有必要,我会 post 更多代码。
不确定这是否对您有帮助,但请检查创建的用户是否处于活动状态。也可能是 django documentation
中提到的未正确设置 cookie 的问题
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’.
编辑:
我设法通过仅使用具有加密密码的用户来解决这个问题。这就是为什么我的管理员可以登录但不能登录我在管理站点中创建的任何用户的原因。
我可以使用超级用户登录我的站点,但我创建的帐户获得的登录页面无效。我使用的是 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)
我删除的字段是用户字段。 如有必要,我会 post 更多代码。
不确定这是否对您有帮助,但请检查创建的用户是否处于活动状态。也可能是 django documentation
中提到的未正确设置 cookie 的问题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’.
编辑:
我设法通过仅使用具有加密密码的用户来解决这个问题。这就是为什么我的管理员可以登录但不能登录我在管理站点中创建的任何用户的原因。