mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 19:43:59 +03:00
Merge pull request #364 from mjs7231/master
Fix for bug #363: ChoiceField missing in renderers.py
This commit is contained in:
commit
b8fa379e50
|
@ -281,6 +281,7 @@ class BrowsableAPIRenderer(BaseRenderer):
|
||||||
serializers.DateField: forms.DateField,
|
serializers.DateField: forms.DateField,
|
||||||
serializers.EmailField: forms.EmailField,
|
serializers.EmailField: forms.EmailField,
|
||||||
serializers.CharField: forms.CharField,
|
serializers.CharField: forms.CharField,
|
||||||
|
serializers.ChoiceField: forms.ChoiceField,
|
||||||
serializers.BooleanField: forms.BooleanField,
|
serializers.BooleanField: forms.BooleanField,
|
||||||
serializers.PrimaryKeyRelatedField: forms.ChoiceField,
|
serializers.PrimaryKeyRelatedField: forms.ChoiceField,
|
||||||
serializers.ManyPrimaryKeyRelatedField: forms.MultipleChoiceField,
|
serializers.ManyPrimaryKeyRelatedField: forms.MultipleChoiceField,
|
||||||
|
@ -316,6 +317,9 @@ class BrowsableAPIRenderer(BaseRenderer):
|
||||||
try:
|
try:
|
||||||
fields[k] = field_mapping[v.__class__](**kwargs)
|
fields[k] = field_mapping[v.__class__](**kwargs)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
if getattr(v, 'choices', None) is not None:
|
||||||
|
fields[k] = forms.ChoiceField(**kwargs)
|
||||||
|
else:
|
||||||
fields[k] = forms.CharField(**kwargs)
|
fields[k] = forms.CharField(**kwargs)
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user