Opened 10 years ago

Closed 10 years ago

#6365 closed (fixed)

parent needs blank=True on "Relating an object to itself, many-to-one"

Reported by: David Grant Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


On this many-to-one self relation example parent needs to have blank=True or else forms won't validate in admin when trying to create a root-level category.

from django.db import models

class Category(models.Model):
    name = models.CharField(max_length=20)
    parent = models.ForeignKey('self', null=True, blank=True, related_name='child_set')

    def __unicode__(self):

Change History (1)

comment:1 Changed 10 years ago by Gary Wilson

Resolution: fixed
Status: newclosed

(In [7015]) Fixed #6365 -- Added blank=True to parent attribute of m2o_recursive model example, thanks dgrant.

Note: See TracTickets for help on using tickets.
Back to Top