Django认证定制

Django认证定制,django,Django,我想定制django auth应用程序,因为默认的auth应用程序不能满足项目的所有需要。然后我通过检查这里的django文档,自己找到了答案。我试图准确地做那个例子。最后,我在my settings.py中添加了AUTH\u USER\u MODEL=“intelic\u AUTH.MyUser”设置。但当我尝试运行“python manage.py syncdb”时,我在下面遇到了这个错误。我不知道为什么。如果有人能帮我解决这个问题,我将不胜感激 CommandError: One or m

我想定制django auth应用程序,因为默认的auth应用程序不能满足项目的所有需要。然后我通过检查这里的django文档,自己找到了答案。我试图准确地做那个例子。最后,我在my settings.py中添加了AUTH\u USER\u MODEL=“intelic\u AUTH.MyUser”设置。但当我尝试运行“python manage.py syncdb”时,我在下面遇到了这个错误。我不知道为什么。如果有人能帮我解决这个问题,我将不胜感激

CommandError: One or more models did not validate:

helpdesk.ticket: 'assigned_to' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

helpdesk.followup: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

helpdesk.savedsearch: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

helpdesk.usersettings: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

helpdesk.ticketcc: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
确保你遵守了文件的规定

粗略地说,它表示您需要更改在FKs中引用用户的方式

使用自定义用户时的正确方法:(文档示例)


另外,如果您阅读了错误信息,似乎已经足够清楚了:
更新关系以指向settings.AUTH\u USER\u MODEL
。由于此错误出现了5次,您需要在models.py文件中的5个位置执行此更改。

我几天前解决了此问题。我试图用一个自定义的用户模型来对用户模型进行子分类,该模型添加了更多的字段

我没有从用户继承,而是改为AbstractUser,一切正常

class Article(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL)