Django

Code

Ticket #6365 (closed: fixed)

Opened 6 months ago

Last modified 6 months ago

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

Reported by: dgrant Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation:
Needs tests: Patch needs improvement:

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

Attachments

Change History

01/12/08 20:19:07 changed by gwilson

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #6365 (parent needs blank=True on "Relating an object to itself, many-to-one")




Change Properties
Action