You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found this issue while trying to use default kwarg with any BooleanField for any model in the project.
After setting default kwarg for model field, admin UI fails to update its value to False: changing False --> True is OK, but changing True --> False doesn't work. After some investigation found this most possible reason:
if (field_has_default and form.add_prefix(f.name) not in form.data and
not getattr(form[f.name].field.widget,
'dont_use_model_field_default_for_empty_data', False)):
continue
Condition above skips on BooleanField update when updating True --> False as field name is not present in form.data when widget value is not set (=False for CheckboxInput case). It is possible to override this behaviour by specifying widget.dont_use_model_field_default_for_empty_data = True for needed BooleanField, however, this looks like a poor workaround that should not be needed.
The text was updated successfully, but these errors were encountered:
It just took me way to long to grep for something monkeypatching django.forms.models.construct_instance. This is a critical issue as it breaks Django's admin form behavior.
Found this issue while trying to use
default
kwarg with any BooleanField for any model in the project.After setting
default
kwarg for model field, admin UI fails to update its value to False: changing False --> True is OK, but changing True --> False doesn't work. After some investigation found this most possible reason:Condition above skips on BooleanField update when updating True --> False as field name is not present in
form.data
when widget value is not set (=False forCheckboxInput
case). It is possible to override this behaviour by specifyingwidget.dont_use_model_field_default_for_empty_data = True
for needed BooleanField, however, this looks like a poor workaround that should not be needed.The text was updated successfully, but these errors were encountered: