Opened 16 years ago
Closed 16 years ago
#9062 closed (duplicate)
admin disallows saving Null fk to more than one object
Reported by: | smcoll | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.0 |
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
from django.db import models from django.contrib.auth.models import User class Contact(models.Model): user = models.ForeignKey(User, unique=True, null=True, blank=True)
In the admin, you can't save more than one model with a Null (-------) fk because you get an error: "Contact with this User already exists."
So it's as if Django is treating the "no relation" selection as an FK itself, and since unique=True, no more than one model can have a Null fk.
In my understanding, the model above should allow for any number of Null relations, but only allow one relation per User instance.
Might possibly be related to #9039.
Note:
See TracTickets
for help on using tickets.
Unless I am missing something, this is more than related to #9039, it is #9039. Admin uses ModelForms, so problems they exhibit will show up in Admin, and fixing it for ModelForms in general will fix it for Admin, so we don't need two open tickets tracking this.