我正在使用django应用程序,我正在使用AUTH_USER_MODEL
的自定义用户模型,即AUTH_USER_MODEL = 'account.User'
我扩展了AbstractBaseUser
类以创建类似于
class User(AbstractBaseUser):
is_provider = models.BooleanField(_('Provider status'), default=False)
USERNAME_FIELD = 'email'
..........
在我的settings.py
文件中,我添加了AUTH_USER_MODEL = 'account.User'
表示现在我的用户模型是accounts.User而不是django.contrib.auth.User。
我想添加django-reviews app app im my webapp来获取评论,但问题是django-reviews使用了DJango.contrib.auth.User作为其默认AUTH_USER_MODEL。
class Review(models.Model):
"""A ``Review`` consists on a comment and a rating.
"""
content_type = models.ForeignKey(ContentType, verbose_name=_(u"Content type"), related_name="content_type_set_for_%(class)s")
content_id = models.PositiveIntegerField(_(u"Content ID"), blank=True, null=True)
content = generic.GenericForeignKey(ct_field="content_type", fk_field="content_id")
# if the user is authenticated we save the user otherwise the name and the
# email.
user = models.ForeignKey(User, verbose_name=_(u"User"), blank=True, null=True, related_name="%(class)s_comments")
session_id = models.CharField(_(u"Session ID"), blank=True, max_length=50)
user_name = models.CharField(_(u"Name"), max_length=50, blank=True)
user_email = models.EmailField(_(u"E-mail"), blank=True)
comment = models.TextField(_(u"Comment"), blank=True)
score = models.FloatField(_(u"Score"), choices=SCORE_CHOICES, default=3.0)
active = models.BooleanField(_(u"Active"), default=False)
creation_date = models.DateTimeField(_(u"Creation date"), auto_now_add=True)
ip_address = models.IPAddressField(_(u"IP address"), blank=True, null=True)
现在它给了我错误
File "/home/user/dir/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 314, in validate
raise CommandError("One or more models did not validate:\n%s" % error_text)
django.core.management.base.CommandError:一个或多个模型未验证: reviews.review:'user'定义了与模型'auth.User'的关系,该模型已被换出。更新关系以指向settings.AUTH_USER_MODEL。
告诉我如何在不使用默认身份验证模型作为我的AUTH_USER_MODEL的情况下,如何在我的应用中使用django-reviews。