Sorry for the confusion in the title.
Now, I have two Comment models (QuestionComment and AnswerComment) that inherit the BaseComment model. I had to do this because each Comment model relates to two different objects (Question and Answer, respectively). However, I was wondering if there's a way to combine these two models into just one, without having to make two different comment models.
Since I have two different comment models for different objects, I have to write numerous duplicate templates , views, and etc.
Any ideas :(((???
Thanks!!
models.py
class BaseComment(models.Model):
comment_author = models.ForeignKey(MyUser, related_name='written_comments')
comment_content = models.CharField(max_length=500)
comment_date = models.DateTimeField(auto_now_add=True)
rating = models.IntegerField(default=0)
class Meta:
abstract = True
class QuestionComment(BaseComment):
question = models.ForeignKey(Question, related_name='comments')
class AnswerComment(BaseComment):
answer = models.ForeignKey(Answer, related_name='comments')