Ticket #12420: t12420.diff

File t12420.diff, 741 bytes (added by Andrii Kurinnyi, 9 years ago)
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index f343a1c..b636105 100644
    a b def construct_instance(form, instance, fields=None, exclude=None): 
    5050            continue
    5151        # OneToOneField doesn't allow assignment of None. Guard against that
    5252        # instead of allowing it and throwing an error.
    53         if isinstance(f, models.OneToOneField) and cleaned_data[f.name] is None:
     53        if isinstance(f, models.OneToOneField) and f.null == False and cleaned_data[f.name] is None:
    5454            continue
    5555        # Defer saving file-type fields until after the other fields, so a
    5656        # callable upload_to can use the values from other fields.
Back to Top