Re: has more than 1 ForeignKey to
Klaas, When you create a Foreign Key to another model, Django also sets up the "reverse relation". If you specify more than one foreign key to the same model, you must give different names for this reverse relationship. http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects js On Nov 10, 3:50 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a UserProfile connected to auth.models.User using > > user = models.ForeignKey(User, unique=True) > > Additionally, I'd like to connect users to each other with manager/ > managed hierarchical relationships, whereby everyone has one manager > (except the big boss who has none): > > manager = models.ForeignKey(User, blank=True, > related_name='employees_userprofile_manager') > > My models fail to load with the exception: > has more than 1 > ForeignKey to > > This doesn't seem logical to me at all: the above is a perfectly fine > example of two foreign keys being meaningful. Why is this not possible > and what is the workaround, or rather, the proper way to do this? > > I'm using Django 1.0. > > Any help is much appreciated. > > regards, > Klaas van Schelven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: has more than 1 ForeignKey to
On Mon, Nov 10, 2008 at 3:50 AM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > Hi all, > > I have a UserProfile connected to auth.models.User using > >user = models.ForeignKey(User, unique=True) > > Additionally, I'd like to connect users to each other with manager/ > managed hierarchical relationships, whereby everyone has one manager > (except the big boss who has none): > >manager = models.ForeignKey(User, blank=True, > related_name='employees_userprofile_manager') > > My models fail to load with the exception: > has more than 1 > ForeignKey to > > This doesn't seem logical to me at all: the above is a perfectly fine > example of two foreign keys being meaningful. Why is this not possible > and what is the workaround, or rather, the proper way to do this? > > I'm using Django 1.0. > > Any help is much appreciated. > I don't know what "fails to load" means -- that is, you haven't made it clear what you are doing when the error is triggered. manage.py runserver? Something in the admin? Also the full traceback would be helpful, since that would give a clue what portion of the Djano code is objecting. As is I suspect you are doing something with inlines but haven't told the admin which ForeignKey to use, see: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#fk-name If that's not it please provide more specifics of what you are doing and the traceback received. Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: has more than 1 ForeignKey to
Try settting related_name on "user" as well. user = models.ForeignKey(User, unique=True, related_name='foo') ME --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
has more than 1 ForeignKey to
Hi all, I have a UserProfile connected to auth.models.User using user = models.ForeignKey(User, unique=True) Additionally, I'd like to connect users to each other with manager/ managed hierarchical relationships, whereby everyone has one manager (except the big boss who has none): manager = models.ForeignKey(User, blank=True, related_name='employees_userprofile_manager') My models fail to load with the exception: has more than 1 ForeignKey to This doesn't seem logical to me at all: the above is a perfectly fine example of two foreign keys being meaningful. Why is this not possible and what is the workaround, or rather, the proper way to do this? I'm using Django 1.0. Any help is much appreciated. regards, Klaas van Schelven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---