I am a making a Q&A site. At present, I have the models as such
class Question(models.Model):
title = models.CharField(max_length=150)
detail = models.TextField()
submitter = models.ForeignKey(User)
date_added = models.DateTimeField(auto_now_add = True)
...# some additional fields such as tags
class Answer(models.Model):
detail = models.TextField()
submitter = models.ForeignKey(User)
date_added = models.DateTimeField(auto_now_add = True)
...
class QuestionVote(models.Model):
voter = models.ForeignKey(User)
question = models.ForeignKey(Question)
#replicating what I did for QuestionVote
class AnswerVote(models.Model):
voter = models.ForeignKey(User)
question = models.ForeignKey(Question)
Question and answer models are the same except a title and tags. To add voting functionality to Answers, I will have to replicate the QuestionVote model as an AnswerVote and repeat everything I did for question voting in the views. I looked a bit into Model Inheritance but if I declare an abstract base class and inherit Question and Answer Models from it then I cannot use foreign keys. So what is the best approach to avoid such repetition?