Code

Opened 7 years ago

Closed 7 years ago

#6365 closed (fixed)

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

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

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 (0)

Change History (1)

comment:1 Changed 7 years ago by gwilson

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.