0
我想跟蹤哪些問題,並回答用戶投票(上下),所以這是我做到了,它不工作如何在django中構建一個voto問題數據庫?
這是我的問題類
class Question(models.Model):
question = models.CharField(max_length = 200)
questionbody = models.TextField()
questioncontent = models.TextField()
author = models.ForeignKey(User)
tags = models.ManyToManyField(Tag)
timestamp = models.DateTimeField('question post date')
upvote = models.IntegerField(default = 0)
downvote = models.IntegerField(default = 0)
view = models.IntegerField(default = 0)
這是我USERPROFILE類(擴展用戶)
class UserProfile(models.Model):
user = models.OneToOneField(User)
tags = models.ManyToManyField(Tag)
# favorite_question = models.ManyToManyField(Question)
# upvote_question = models.ManyToManyField(Question)
# downvote_question = models.ManyToManyField(Question)
# upvote_answer = models.ManyToManyField(Answer)
# downvote_answer = models.ManyToManyField(Answer)
integration = models.IntegerField(default = 0)
level = models.CharField(max_length = 100)
如果取消對該行 運行synvdb命令,它會顯示錯誤
access for m2m field 'favorite-question' clashes with related m2m field 'question-userprofile_set',add a related_name argument to thr definition for 'favorite-question'
和其餘4行顯示相同的錯誤。我真的很新的Django,請幫助
我得到它的工作,thanx無論如何,但你認爲有一個更好的方式來做到這一點,我的意思是upvote和downvote,種類重複,我不能只有一個投票,並以某種方式告訴差異? – paynestrike