Skip to content

Abstract Classes do not have a default manager #2880

Closed
@shredding

Description

@shredding

In pre 2.3 it was possible to have a shared serializer for different models. In my case I have more or less the same invoice class for multiple entities, and had a serializer like this:

class InvoiceSerializer(serializers.ModelSerializer):

    total = serializers.IntegerField(
        read_only=True
    )

    class Meta:
        model = AbstractInvoice
        fields = ('number', 'end_date', 'status', 'total')

This raises an error in line 187 of field mapping.py, because AbstractInvoice does not have a _default_manager.

I could fix the error by setting the field no read-only (I have not added the POST/PUT anyway for that model).

However, it would be great if we could set that field dynamically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions