It doesn't sound to me as though the OP wants OneToOne relation. That's not to say that I know what he wants, but I'm going to guess:
A question can get one, and only one, NEW answer attached to it, but the question can exist before there is such an answer (be unanswered). An answer can get one, and only one, NEW question attached to it, but the answer can exist before there is a follow up question. This isn't quite OneToOne since the ends of the relation need not both exist. My solution is to use a ForeignKey field in each, on the other model. When Q1 receives an answer A1, create A1 and point its foreign key at Q1. The database isn't going to check that there isn't already another answer (maybe someone with more sql chops can compose a constraint), but the view can check first that Q1.answer_set.count() is zero before saving A1. And if you should want to allow multiple answers to a question, and multiple follow-up questions to an answer, just skip the count() check (or constraint). Bill On 6/1/12, Simone Federici <s.feder...@gmail.com> wrote: > class Question(models.Model): > title = models.CharField(max_length = 50) > response = models.CharField(max_length = 400) > parent = models.OneToOne('self', related_name='child', null=True) > > def __unicode__(self): > return self.title > > class Answer(models.Model): > question = models.OneToOne(Question, related_name='answer') > title = models.CharField(max_length = 50) > answer = models.CharField(max_length = 400) > def __unicode__(self): > return self.title > > > On Fri, Jun 1, 2012 at 7:05 PM, Jak <jacob.wisch...@gmail.com> wrote: > >> Think of it kind of like a conversation. >> >> Person A asks a question >> > new Q1 > >> Person B answers >> > new A1->Q1 > >> Person A asks another question >> > new Q2->Q1 > >> Person B gives a different answer. >> > new A2->Q2 > >> >> So for every question there could be an answer and for every answer >> there could be another question >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.