mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-04 15:34:05 +03:00
ModelSerializer.get_field() now returns a ChoiceField if the model has choices.
This commit is contained in:
parent
d1e05ea8d4
commit
91ea57bf98
|
@ -391,6 +391,10 @@ class ModelSerializer(Serializer):
|
||||||
models.CommaSeparatedIntegerField: CharField,
|
models.CommaSeparatedIntegerField: CharField,
|
||||||
models.BooleanField: BooleanField,
|
models.BooleanField: BooleanField,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if model_field.flatchoices: # This ModelField contains choices
|
||||||
|
ret = ChoiceField(model_field.flatchoices)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
ret = field_mapping[model_field.__class__]()
|
ret = field_mapping[model_field.__class__]()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user