Adding ForeignKey on self to User with add_to_class causes endless loop in the server
10 views
Skip to first unread message
Daniel Kvasnicka jr.
unread,
Jul 31, 2007, 2:57:46 AM7/31/07
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi, in my models.py I'm tring to add some fields to User with add_to_class (so I can access them in admin). Everything works fine, only when I try to add a ForeignKey on User itself, Django dev server gets in a loop and has to be killed or it consumes every byte of memory and all processor time.
I do it like this: User.add_to_class('parent', models.ForeignKey('User', blank = True, default = 0))
Anybody experienced something similar?
Thanks for every thought, Dan
Ben Ford
unread,
Jul 31, 2007, 3:30:58 AM7/31/07
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
I'm not sure about the mechanics of add_to_class, but usually a self referential ForeignKey should look like: models.ForeignKey('self', ......) Have you tried it like this? Ben
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
On Jul 31, 9:30 am, "Ben Ford" <ben.for...@gmail.com> wrote: > I'm not sure about the mechanics of add_to_class, but usually a self > referential ForeignKey should look like: > models.ForeignKey('self', ......) > Have you tried it like this?