Friday, June 1, 2012

Re: Django/Python Circular model reference

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 kind of like a conversation.

Person A asks a question
Person B answers
Person A asks another question
Person B gives a different answer.

So for every question there could be an answer and for every answer
there could be another question

Thanks again!

On Jun 1, 12:51 pm, Simone Federici <s.feder...@gmail.com> wrote:
> 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 <kevin.s.anth...@gmail.com>wrote:
>
>
>
>
>
>
>
> > 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" <jacob.wisch...@gmail.com> 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
>
> >> Jak
>
> >> On Jun 1, 12:08 pm, Javier Guerra Giraldez <jav...@guerrag.com> wrote:
> >> > On Fri, Jun 1, 2012 at 10:42 AM, Jak <jacob.wisch...@gmail.com> 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 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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment