api.v1.serializers.correspondent_serializers package

api.v1.serializers.Correspondent_serializers package containing serializers for the core.models.Correspondent data.

class api.v1.serializers.correspondent_serializers.BaseCorrespondentSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

The base serializer for core.models.Correspondent.

Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for core.models.Correspondent should inherit from this.

class Meta[source]

Bases: object

Metadata class for the base serializer.

Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this. read_only_fields must not be shortened in subclasses.

model

alias of Correspondent

exclude: Final[list[str]] = ['user']

Exclude only the core.models.Correspondent.Correspondent.user field.

read_only_fields: Final[list[str]] = ['email_address', 'email_name', 'list_id', 'list_owner', 'list_subscribe', 'list_unsubscribe', 'list_unsubscribe_post', 'list_post', 'list_help', 'list_archive', 'created', 'updated']

The core.models.Correspondent.Correspondent.email_address, core.models.Correspondent.Correspondent.created and core.models.Correspondent.Correspondent.updated fields are read-only.

_declared_fields = {}
class api.v1.serializers.correspondent_serializers.CorrespondentSerializer(*args, **kwargs)[source]

Bases: BaseCorrespondentSerializer

The standard serializer for a core.models.Correspondent.Correspondent.

Includes a nested serializer for the core.models.Correspondent.Correspondent.emails field.

emails

The emails are set from the core.models.EmailCorrespondent.EmailCorrespondent via :fu`core.models.EmailCorrespondent`

_declared_fields = {'emails': SerializerMethodField(read_only=True)}
get_emails(instance)[source]

Serializes the emails connected to the instance to be serialized.

Parameters:

instance (Correspondent) – The instance being serialized.

Return type:

ReturnDict[str, Any]

Returns:

The serialized emails connected to the instance to be serialized. An empty list if the the user is not authenticated.

Submodules