admin disallows saving Null fk to more than one object
|Reported by:||smcoll||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.