0

I am working on a django App where I am using a custom user models for AUTH_USER_MODEL i.e AUTH_USER_MODEL = 'account.User'I extended the AbstractBaseUser class to create my model that is like

class User(AbstractBaseUser):
    is_provider = models.BooleanField(_('Provider status'), default=False)
    USERNAME_FIELD = 'email'
    ..........

In my settings.py file i added AUTH_USER_MODEL = 'account.User' means now my User model is accounts.User not django.contrib.auth.User.

I want to add django-reviews app app im my webapp to get the reviews but the problem is django-reviews used DJango.contrib.auth.User as its default 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)

now it is giving me error

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: One or more models did not validate: reviews.review: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

Tell me a way that how can i use the django-reviews with my app while not using the default auth model as my AUTH_USER_MODEL.

Sajid Ahmad
  • 1,124
  • 4
  • 18
  • 40

0 Answers0