I'm running into this error when I attempt to syncdb:
auth.user: The model User has two manually-defined m2m relations through the model FavoriteQuestion, which is not permitted. Please consider using an extra field on your intermediary model instead.
I'm really don't understand what it means because I only see 1 model-to-model relations in the model FavoriteQuestion.
class FavoriteQuestion(models.Model):
"""A favorite Question of a User."""
question = models.ForeignKey(Question)
user = models.ForeignKey(User, related_name='user_favorite_questions')
added_at = models.DateTimeField(default=datetime.datetime.now)
class Meta:
db_table = u'favorite_question'
def __unicode__(self):
return '[%s] favorited at %s' %(self.user, self.added_at)
I'm not sure if this is important, but this is also in the models.py file.
User.add_to_class('favorite_questions',
models.ManyToManyField(Question, through=FavoriteQuestion,
related_name='favorited_by'))
edit added Question model
Django 1.1.1
class Question(models.Model):
title = models.CharField(max_length=300)
author = models.ForeignKey(User, related_name='questions')
added_at = models.DateTimeField(default=datetime.datetime.now)
tags = models.ManyToManyField(Tag, related_name='questions')
# Status
wiki = models.BooleanField(default=False)
wikified_at = models.DateTimeField(null=True, blank=True)
answer_accepted = models.BooleanField(default=False)
closed = models.BooleanField(default=False)
closed_by = models.ForeignKey(User, null=True, blank=True, related_name='closed_questions')
closed_at = models.DateTimeField(null=True, blank=True)
close_reason = models.SmallIntegerField(choices=CLOSE_REASONS, null=True, blank=True)
deleted = models.BooleanField(default=False)
deleted_at = models.DateTimeField(null=True, blank=True)
deleted_by = models.ForeignKey(User, null=True, blank=True, related_name='deleted_questions')
locked = models.BooleanField(default=False)
locked_by = models.ForeignKey(User, null=True, blank=True, related_name='locked_questions')
locked_at = models.DateTimeField(null=True, blank=True)
# Denormalised data
score = models.IntegerField(default=0)
vote_up_count = models.IntegerField(default=0)
vote_down_count = models.IntegerField(default=0)
answer_count = models.PositiveIntegerField(default=0)
comment_count = models.PositiveIntegerField(default=0)
view_count = models.PositiveIntegerField(default=0)
offensive_flag_count = models.SmallIntegerField(default=0)
favourite_count = models.PositiveIntegerField(default=0)
last_edited_at = models.DateTimeField(null=True, blank=True)
last_edited_by = models.ForeignKey(User, null=True, blank=True, related_name='last_edited_questions')
last_activity_at = models.DateTimeField(default=datetime.datetime.now)
last_activity_by = models.ForeignKey(User, related_name='last_active_in_questions')
tagnames = models.CharField(max_length=125)
summary = models.CharField(max_length=180)
html = models.TextField()
comments = generic.GenericRelation(Comment)
votes = generic.GenericRelation(Vote)
flagged_items = generic.GenericRelation(FlaggedItem)
email_feeds = generic.GenericRelation(EmailFeed)
objects = QuestionManager()