model serializer field kwargs for blank=True charfield #8492
Unanswered
Alasdair321
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In terms of Django model field kwargs, blank=True allows model forms to submit empty values, these are stored as an empty string in the database.
In DRF, using a model serializer with a model with characteristics as follows:
Produces serializer field kwargs as follows (using the method
rest_framework.utils.get_field_kwargs
):DRF has introduced a new and problematic kwarg:
required: False
as it foundblank=True
in the model field kwargs.I believe the intended behaviour should be something like:
If field kwargs blank and not null -> required = True & default = ""
This would adhere to the behaviour of the model.
Beta Was this translation helpful? Give feedback.
All reactions