Hello everyone,

I'm new to Django and trying to set up a small website with it. I've only
started creating the model and already got a few troubles!

1. I need to relate an object to itself! For example if my object is a
Person, I want to have a field mother which will be the key of an other
Person record. But since the model Person is not defined it doesn't work so
I tried:

class Person(models.Model):
    ...
    mother = models.ForeignKey('Person')
    ...

Will this work?

2. I need to have many fields that are ForeignKeys of the same kind of
objects but don't want a many to many relation as I know that there will
always be the same small number of references.
For example if I've got a Body class and a Legs class, I know that I'll
never have a body with more than 2 legs and it would be easier to have a
leftLeg = ForeignKey(Leg) field
and a
rightLeg = ForeignKey(Leg) field

but this causes many errors when I try to validate my model.

Error:
Accessor for field leftLeg clashes with related field Leg.<project
name>__set. Add a related name argument to the definition for leftLeg

which really doesn't mean anything to me.

Is it possible to do those kind of things? How?

Thanks


--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to