Django 1.6尝试使用AbstractUser向User Object添加字段时出现问题

时间:2014-03-10 15:43:56

标签: python django

我正在尝试在Django 1.6中为用户模型添加几个字段。我宁愿将它们直接添加到User对象而不是创建配置文件。但是,我遇到了以下问题:

models.py:

class Employee(AbstractUser):
    emp_irc_name = models.CharField(max_length="25")
    emp_forum_username = models.CharField(max_length="25")

错误输出:

(bot)one@chat-dash /home/git/bot_server/bot_server $ python manage.py syncdb
CommandError: One or more models did not validate:
auth.user: Accessor for m2m field 'groups' clashes with related m2m field 'Group.user_set'. Add a related_name argument to the definition for 'groups'.
auth.user: Accessor for m2m field 'user_permissions' clashes with related m2m field 'Permission.user_set'. Add a related_name argument to the definition for 'user_permissions'.
bot_data.employee: Accessor for m2m field 'groups' clashes with related m2m field 'Group.user_set'. Add a related_name argument to the definition for 'groups'.
bot_data.employee: Accessor for m2m field 'user_permissions' clashes with related m2m field 'Permission.user_set'. Add a related_name argument to the definition for 'user_permissions'.

(bot)one@chat-dash /home/git/bot_server/bot_server $

1 个答案:

答案 0 :(得分:2)

你需要告诉Django不要创建标准的auth.User模型。您可以通过在settings.py中指定AUTH_USER_MODEL来执行此操作:

AUTH_USER_MODEL = 'bot_data.Employee'