paperap.models.document_type.model module

Document type model for Paperless-NgX.

This module provides the DocumentType model class for interacting with document types in a Paperless-NgX instance. Document types are used to categorize documents and can be configured with matching rules for automatic classification.

class paperap.models.document_type.model.DocumentType(**data)[source]

Bases: StandardModel, MatcherMixin

Represents a document type in Paperless-NgX.

Document types are used to categorize documents and can be configured with matching rules for automatic classification of new documents during consumption.

The MatcherMixin provides functionality for pattern matching against document content or metadata.

name

The name of the document type.

Type:

str

slug

A unique identifier for the document type, auto-generated from name if not provided.

Type:

str, optional

match

The pattern used for matching documents. Only available when using the MatcherMixin methods.

Type:

str, optional

matching_algorithm

The algorithm used for matching. Only available when using the MatcherMixin methods.

Type:

MatchingAlgorithmType, optional

is_insensitive

Whether the matching is case insensitive. Only available when using the MatcherMixin methods.

Type:

bool, optional

document_count

The number of documents of this type (read-only).

Type:

int

owner

The ID of the user who owns this document type.

Type:

int, optional

user_can_change

Whether the current user can modify this document type.

Type:

bool, optional

Examples

Create a new document type:

>>> doc_type = client.document_types.create(
...     name="Invoice",
...     matching_algorithm="auto",
...     match="invoice"
... )

Update an existing document type:

>>> doc_type = client.document_types.get(1)
>>> doc_type.name = "Receipt"
>>> doc_type.save()
Parameters:

data (Any)

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

Bases: Meta

Metadata for the DocumentType model.

Defines read-only fields and the associated queryset class.

Parameters:

model (type[_Self])

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

alias of DocumentTypeQuerySet

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 document type.

Returns:

A queryset containing all documents that have

this document type assigned.

Return type:

DocumentQuerySet

Examples

Get all documents of this type:

>>> documents = doc_type.documents
>>> for doc in documents:
...     print(doc.title)

Filter documents of this type:

>>> recent_docs = doc_type.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