having this two classes I always have a doubt of which is the best practice “linking” them ( if any)
Question
class Question(models.Model):
text = models.CharField('Question',max_length=120)
created = models.DateTimeField(auto_now_add=True)
opens = models.DateTimeField()
closes = models.DateTimeField()
Answer
class Answer(models.Model):
text = models.CharField('Answer',max_length=120)
votes = models.IntegerField(default=0)
Wrong – I can add this line to Answer (this was a copy / paste error):
answers = models.ForeignKey(Answer)
Edit:
answers = models.ManyToManyField(Answer)
I can add this line to Answer:
question = models.ForeignKey(Question)
I would like to know if it really doesn’t matter or I should consider different aspects.
Thanks!
An question has to have answers. You don’t make an answer (usually) to answer multiple questions, instead, an answer answers one particular question, but there may be multiple answers (from different users for example). Therefore I’d pick 4 .