There's a proposal to remove this behavior:
>>> obj.fk = None
ValueError('Cannot assign None: "Obj.fk" does not allow null values.)
(i.e. no more exception if you assign None to a non-nullable foreign key)
Rationale presented on the ticket [1]:
Any concerns with this?
Its removal helps fix an edge case that regressed in Django 1.8 where if you have a model field with blank=False but required=False on the form field, an empty form value will be silently ignored and won't overwrite a model instance's value. I think it's a sufficient edge case, however, that it's not worth backporting this change (if accepted).
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a79c63a4-abdf-4cbd-bf96-a4bc2d5b537b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There's a proposal to remove this behavior:
>>> obj.fk = None
ValueError('Cannot assign None: "Obj.fk" does not allow null values.)
There's a proposal to remove this behavior:
>>> obj.fk = None
ValueError('Cannot assign None: "Obj.fk" does not allow null values.)
Model.save()
to allow easier usage
of in-memory models (#25160).