Opened 17 years ago
Closed 17 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: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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): return self.name
Note:
See TracTickets
for help on using tickets.
(In [7015]) Fixed #6365 -- Added
blank=True
to parent attribute ofm2o_recursive
model example, thanks dgrant.