On Mon, Jun 21, 2010 at 10:37 AM, Magnus Valle <wisca...@gmail.com> wrote:
> Hi, > I'm trying to make model that has itself as a foreign key, in an > attempt to store a reverse tree in Django. > However, I can't find a way to set a default value to > models.ForeignKey or make it optional. > > My model is like this: > class Node(models.Model): > name = models.CharField(max_length=100) > parent = models.ForeignKey('self') > > runserver doesn't complain, but whenever I try to enter data to the > model with Django's admin interface I get a "This field is required." > message, and it want's me to select a entry, but there are none. > You make a ForeignKey field optional by specifying blank=True, null=True: http://docs.djangoproject.com/en/1.2/ref/models/fields/#null Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.