Re: Django/Python Circular model reference

2012-06-01 Thread Pato Valarezo
It's a typical question->answer->customer scenario, a question has many answers (and just one of them may be correct), and many customers have many different answers. I'd do: Customer <-(many to many)-> Answer Question -(has many)-> Answer Your last error means than you are not naming correct

Re: Django/Python Circular model reference

2012-06-01 Thread Simone Federici
On Fri, Jun 1, 2012 at 8:58 PM, Bill Freeman wrote: > This isn't quite OneToOne since the ends of the relation need not both > exist. An answer cannot exist without the question The following question cannot exist without the previous answer, but there is the case where the object Question is t

Re: Django/Python Circular model reference

2012-06-01 Thread Bill Freeman
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,

Re: Django/Python Circular model reference

2012-06-01 Thread Simone Federici
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.OneT

Re: Django/Python Circular model reference

2012-06-01 Thread Jak
When I use 'Question' as a string i get the following error "Error: One or more models did not validate: users.answer: Reverse query name for m2m field 'customer_response' clashes with m2m field 'Question.answer'. Add a related_name argument to the definition for 'customer_response'. Think of it

Re: Django/Python Circular model reference

2012-06-01 Thread Simone Federici
you can use 'Question' as String (lazy reference) ManyToMany('Question') but I don't really undestand your relations On Fri, Jun 1, 2012 at 6:42 PM, Kevin Anthony wrote: > Define it in one and back reference it in the other > > Kevin > Please excuse brevity, sent from phone > On Jun 1, 2012 12:

Re: Django/Python Circular model reference

2012-06-01 Thread Kevin Anthony
Define it in one and back reference it in the other Kevin Please excuse brevity, sent from phone On Jun 1, 2012 12:38 PM, "Jak" wrote: > The problem that I'm having is that the model "Question" is not > defined since I am referencing it after I use it in the Answer > model. > > > Thanks > >

Re: Django/Python Circular model reference

2012-06-01 Thread Jak
The problem that I'm having is that the model "Question" is not defined since I am referencing it after I use it in the Answer model. Thanks Jak On Jun 1, 12:08 pm, Javier Guerra Giraldez wrote: > On Fri, Jun 1, 2012 at 10:42 AM, Jak wrote: > > Each answer has > > a question, and each que

Re: Django/Python Circular model reference

2012-06-01 Thread Javier Guerra Giraldez
On Fri, Jun 1, 2012 at 10:42 AM, Jak wrote: > Each answer has > a question, and each question has an answer use OneToOneField relationships (https://docs.djangoproject.com/en/1.4/ref/models/fields/#onetoonefield) -- Javier -- You received this message because you are subscribed to the Google

Django/Python Circular model reference

2012-06-01 Thread Jak
Hi all, I am trying to create two django models that reference each other. 1 model is a question and the other model is an answer. Each answer has a question, and each question has an answer. I cant seem to get it to work without error. Below is the code. from django.db import models cl