Not possible to override serializer_field_mappings with a field that has choices (for example a from ChoiceField derived field)

Author: gabn88Created Dec 4, 2023Updated Sep 12, 2026

Because of this line:

https://github.com/encode/django-rest-framework/blame/0abb84fa3955956fc6156cc2c51222cd4ceae783/rest_framework/serializers.py#L1286

If you set a serializer_field_mapping to for example a fields.CountryField: serializer_fields.CountryField (from django_countries), it will be replaced by a 'dumb' ChoiceField and the serialization will fail. This makes that you have to manually set this field on every serializer and the serializer_field_mapping mechanism won't work.

Another example is the TimeZoneField (if you use the extended version that shows the choices via the OPTIONS request).

Source: encode/django-rest-framework