BooleanField default not respected on ModelSerializer #8977
Unanswered
brauhausdc
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.
-
I defined a field in a model as:
...
run_at_intervals = models.BooleanField(
default=False,
choices=[
(True, "True"),
(False, "False"),
],
)
...
and then listed it as one of the fields in a "serializers.HyperlinkedModelSerializer" - When I used that in a "generics.CreateAPIView", it would put up "True" as the default setting. Switching the order of the True / False settings in the Model Class fixed my issue. The field definition in the model now reads:
run_at_intervals = models.BooleanField(
default=False,
choices=[
(False, "False"),
(True, "True"),
],
)
Beta Was this translation helpful? Give feedback.
All reactions