On May 2, 8:48 am, Anthony <alantho...@gmail.com> wrote: > I'm trying to instantiate a recursive object model via the admin, but > am getting an error. > > My model: > > class Bracket(models.Model): > m = models.ForeignKey(OtherModel) > parent = models.ForeignKey('self', blank=True, null=True) > name = models.CharField(max_length = 30) > > The error: > > IntegrityError at /admin/myapp/bracket/add/ > > myapp_bracket.parent_id may not be NULL > > Request Method: POST > Request URL: http://mysite/admin/myapp/bracket/add/ > Exception Type: IntegrityError > Exception Value: > > myapp_bracket.parent_id may not be NULL > > What do I need to let the admin interface allow me to enter a root > level instance? I was able to enter the brackets via the shell, so I > think the model is set up properly.
No, you need to allow null=True on the foreign key, otherwise you can't have a top-level parent bracket. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---