Allowing custom Serializer Fields to have different BrowsableApiRendered Form Fields than CharField

moved field_mapping
from local serializer_to_form_fields var
to BrowsableAPIRenderer class attr
This commit is contained in:
Ludwig Kraatz 2012-11-08 14:58:53 +01:00
parent b4b860b45b
commit 08fef1ac81

View File

@ -259,21 +259,21 @@ class BrowsableAPIRenderer(BaseRenderer):
format = 'api' format = 'api'
template = 'rest_framework/api.html' template = 'rest_framework/api.html'
field_mapping = { field_mapping = {
serializers.FloatField: forms.FloatField, serializers.FloatField: forms.FloatField,
serializers.IntegerField: forms.IntegerField, serializers.IntegerField: forms.IntegerField,
serializers.DateTimeField: forms.DateTimeField, serializers.DateTimeField: forms.DateTimeField,
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.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,
serializers.SlugRelatedField: forms.ChoiceField, serializers.SlugRelatedField: forms.ChoiceField,
serializers.ManySlugRelatedField: forms.MultipleChoiceField, serializers.ManySlugRelatedField: forms.MultipleChoiceField,
serializers.HyperlinkedRelatedField: forms.ChoiceField, serializers.HyperlinkedRelatedField: forms.ChoiceField,
serializers.ManyHyperlinkedRelatedField: forms.MultipleChoiceField serializers.ManyHyperlinkedRelatedField: forms.MultipleChoiceField
} }
def get_default_renderer(self, view): def get_default_renderer(self, view):
""" """