Resetting a CharFiled to an empty string after fix for #3130 · Issue #3318 · encode/django-rest-framework (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Commit d231f36 to fix #3130 added the following check to fields.Field.get_value()
:
elif ret == '' and self.default:
return empty
Maybe I am wrong, but it looks like with this change it is no longer possible to reset a CharField
with allow_blank=True
but no default
argument which currently has a non-empty value back to an empty string: The default value for the default
argument is the empty
marker. Since the validate_empty_values()
method raises a SkipField
execption for this marker the field is skipped on update if set to an empty string.
To work around this problem the field may be defined with the empty string as default
argument, but to have both allow_blank=True
and default=''
in the field's argument list seems counter-intuitive.