Django REST Framework

class EmbeddedModelSerializer(*args: Any, **kwargs: Any)

Serializer for EmbeddedModel instances.

Subclass and set Meta.model and Meta.fields:

class AddressSerializer(EmbeddedModelSerializer):
    class Meta:
        model = Address
        fields = '__all__'

EmbeddedModelSerializer auto-generates DRF fields from the embedded model’s field definitions, including nested EmbeddedModelField and EmbeddedModelArrayField. Explicitly declared fields on a subclass take priority over auto-generated ones.

class MongoModelSerializer(*args: Any, **kwargs: Any)

ModelSerializer with automatic support for MongoDB-specific fields.

EmbeddedModelField, EmbeddedModelArrayField, ArrayField, PolymorphicEmbeddedModelField, and PolymorphicEmbeddedModelArrayField are detected automatically:

class BookSerializer(MongoModelSerializer):
    class Meta:
        model = Book
        fields = '__all__'

Explicit field declarations override the auto-generated fields:

class BookSerializer(MongoModelSerializer):
    author = AuthorSerializer()

    class Meta:
        model = Book
        fields = '__all__'
class PolymorphicEmbeddedModelSerializer(*args: Any, **kwargs: Any)

Read-only serializer for PolymorphicEmbeddedModelField values.

Serialize each instance using an auto-generated EmbeddedModelSerializer for its concrete type. A _label key (e.g. "myapp.Dog") is included in the output so consumers can identify the concrete type. Write operations are not supported because PolymorphicEmbeddedModelField is not editable.