paperap.models.correspondent.model module

Define the Correspondent model for interacting with Paperless-NgX correspondents.

This module provides the Correspondent model class, which represents a person, company, or organization that sends or receives documents in Paperless-NgX. Correspondents help organize documents and make them easier to find.

class paperap.models.correspondent.model.Correspondent(**data)[source]

Bases: StandardModel, MatcherMixin

Represent a correspondent in Paperless-NgX.

A correspondent typically represents a person, company, or organization that sends or receives documents. Correspondents can be assigned to documents to help with organization and searching.

slug

URL-friendly identifier for the correspondent, auto-generated.

name

Display name of the correspondent.

document_count

Number of documents associated with this correspondent.

owner

ID of the user who owns this correspondent.

user_can_change

Whether the current user has permission to modify this correspondent.

Examples

Create a new correspondent:
>>> correspondent = client.correspondents.create(name="Electric Company")
Assign a correspondent to a document:
>>> document = client.documents.get(123)
>>> document.correspondent = correspondent.id
>>> document.save()
Parameters:

data (Any)

slug: str | None
name: str | None
document_count: int
owner: int | None
user_can_change: bool | None
class Meta(model)[source]

Bases: Meta

Define metadata for the Correspondent model.

Specifies read-only fields and the associated queryset class for the Correspondent model.

read_only_fields

Set of field names that cannot be modified.

queryset

The queryset class to use for this model.

Parameters:

model (type[_Self])

read_only_fields: ClassVar[set[str]] = {'document_count', 'id', 'slug'}
queryset

alias of CorrespondentQuerySet

blacklist_filtering_params: ClassVar[set[str]] = {}
field_map: dict[str, str] = {}
filtering_disabled: ClassVar[set[str]] = {}
filtering_fields: ClassVar[set[str]] = {'_resource', 'document_count', 'id', 'name', 'owner', 'slug', 'user_can_change'}
supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
model: type[_Self]
name: str
property documents: DocumentQuerySet

Get all documents associated with this correspondent.

Provides a convenient way to access all documents that have been assigned to this correspondent without having to construct a filter.

Returns:

A queryset containing all documents associated with this correspondent.

Examples

Get all documents for a correspondent:
>>> correspondent = client.correspondents.get(5)
>>> docs = correspondent.documents
>>> print(f"Found {docs.count()} documents")
Filter documents further:
>>> recent_docs = correspondent.documents.filter(created__gt="2023-01-01")
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'populate_by_name': True, 'use_enum_values': True, 'validate_assignment': True, 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

id: int