Open nemesifier opened 10 years ago
Or you can simple use property:
@property
def field_mapping(self):
field_mapping = super(HStoreSerializer, self).field_mapping.copy()
field_mapping[HStoreDict] = HStoreField
field_mapping[DictionaryField] = HStoreField
return field_mapping
Thanks. To support also the VirtualFields is not that few lines of code unfortunately.
https://github.com/djangonauts/django-rest-framework-hstore/blob/master/rest_framework_hstore/serializers.py#L31
An approach like the one used on django-rest-framework-gis might be better for maintainability: https://github.com/djangonauts/django-rest-framework-gis/blob/master/rest_framework_gis/serializers.py#L9