This seems indeed to be the solution!

class Host(models.Model):
   [...]
   person_in_charge = models.ForeignKey(Person,
         related_name='hosts_in_primary_charge_set')
   backup_person = models.ForeignKey(Person,
         related_name='hosts_in_secondary_charge_set')

Thanks.

Le mardi 18 juillet 2006 15:32, Corey Oordt a écrit :
> Take a look at this page for a start:
> http://www.djangoproject.com/documentation/models/m2o_recursive2/
>
> It's for one-to-many, but it might work...
>
> Corey
>
> On Jul 18, 2006, at 3:20 PM, Guillaume Pratte wrote:
> > Hello,
> >
> > I have an error with a model and would like to know if it is something
> > impossible to do in Django or should be considered a bug...
> >
> > I modeled a rudimentary inventory system : I have Hosts and Persons
> > responsible for them (Admin class omitted).
> >
> > class Person(models.Model):
> >         name = models.CharField(maxlength=100)
> >
> > class OperatingSystem(models.Model):
> >         name = models.CharField(maxlength=100)
> >         version = models.CharField(maxlength=20)
> >
> > class Host(models.Model):
> >         name = models.CharField(maxlength=100)
> >         os = models.ForeignKey(OperatingSystem)
> >         ip = models.IPAddressField()
> >         person_in_charge = models.ForeignKey(Person)
> >         backup_person = models.ForeignKey(Person)
> >
> >
> > Django gives me the following error when validating the models :
> >
> > Validating models...
> > invs.host: Accessor for field 'person_in_charge' clashes with related
> > field 'Person.host_set'. Add a related_name argument to the definition
> > for 'person_in_charge'.
> > invs.host: Accessor for field 'backup_person' clashes with related
> > field 'Person.host_set'. Add a related_name argument to the definition
> > for 'backup_person'.
> > 2 errors found.
> >
> >
> > If I comment out "backup_person", it works.
> >
> > I don't want to use a ManyToMany relationship, because then would
> > not be able
> > to differentiate the principal from the backup.
> >
> > Is there a way around?
> >
> > Thanks,
> >
> > Guillaume Pratte
>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to