paperap.models.document package
METADATA:
- File: __init__.py
Project: paperap
- Created: 2025-03-04
Version: 0.0.10
Author: Jess Mann Email: jess@jmann.me
Copyright (c) 2025 Jess Mann
LAST MODIFIED:
2025-03-04 By Jess Mann
- class paperap.models.document.Document(**data)[source]
Bases:
StandardModelRepresents a Paperless-NgX document.
- added
The timestamp when the document was added to the system.
- archive_serial_number
The serial number of the archive.
- archived_file_name
The name of the archived file.
- content
The content of the document.
- correspondent
The correspondent associated with the document.
- created
The timestamp when the document was created.
- created_date
The date when the document was created.
- updated
The timestamp when the document was last updated.
- custom_fields
Custom fields associated with the document.
- deleted_at
The timestamp when the document was deleted.
- document_type
The document type associated with the document.
Whether the document is shared by the requester.
- notes
Notes associated with the document.
- original_filename
The original file name of the document.
- owner
The owner of the document.
- page_count
The number of pages in the document.
- storage_path
The storage path of the document.
- tags
The tags associated with the document.
- title
The title of the document.
- user_can_change
Whether the user can change the document.
- checksum
The checksum of the document.
Examples
>>> document = client.documents().get(pk=1) >>> document.title = 'Example Document' >>> document.save() >>> document.title 'Example Document'
# Get document metadata >>> metadata = document.get_metadata() >>> print(metadata.original_mime_type)
# Download document >>> download = document.download() >>> with open(download.disposition_filename, ‘wb’) as f: … f.write(download.content)
# Get document suggestions >>> suggestions = document.get_suggestions() >>> print(suggestions.tags)
- Parameters:
data (
Any)
- class Meta(model)[source]
Bases:
Meta- Parameters:
model (type[_Self])
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {'correspondent': 'correspondent_id', 'custom_fields': 'custom_field_dicts', 'document_type': 'document_type_id', 'storage_path': 'storage_path_id', 'tags': 'tag_ids'}
- filtering_disabled: ClassVar[set[str]] = {'deleted_at', 'is_shared_by_requester', 'page_count'}
- filtering_fields: ClassVar[set[str]] = {'__search_hit__', '_correspondent', '_document_type', '_resource', '_storage_path', 'added', 'archive_checksum', 'archive_filename', 'archive_serial_number', 'archived_file_name', 'checksum', 'content', 'correspondent_id', 'created', 'created_date', 'custom_field_dicts', 'document_type_id', 'filename', 'id', 'notes', 'original_filename', 'owner', 'storage_path_id', 'storage_type', 'tag_ids', 'title', 'user_can_change'}
- filtering_strategies: ClassVar[set[FilteringStrategies]] = {FilteringStrategies.WHITELIST}
- read_only_fields: ClassVar[set[str]] = {'archived_file_name', 'deleted_at', 'id', 'is_shared_by_requester', 'page_count'}
- supported_filtering_params: ClassVar[set[str]] = {'added__date__gt', 'added__date__lt', 'added__day', 'added__gt', 'added__lt', 'added__month', 'added__year', 'archive_serial_number', 'archive_serial_number__gt', 'archive_serial_number__gte', 'archive_serial_number__isnull', 'archive_serial_number__lt', 'archive_serial_number__lte', 'checksum__icontains', 'checksum__iendswith', 'checksum__iexact', 'checksum__istartswith', 'content__contains', 'content__icontains', 'content__iendswith', 'content__iexact', 'content__istartswith', 'correspondent__id', 'correspondent__id__in', 'correspondent__id__none', 'correspondent__isnull', 'correspondent__name__icontains', 'correspondent__name__iendswith', 'correspondent__name__iexact', 'correspondent__name__istartswith', 'correspondent__slug__iexact', 'created__date__gt', 'created__date__lt', 'created__day', 'created__gt', 'created__lt', 'created__month', 'created__year', 'custom_field_query', 'custom_fields__icontains', 'custom_fields__id__all', 'custom_fields__id__in', 'custom_fields__id__none', 'document_type__id', 'document_type__id__in', 'document_type__id__none', 'document_type__isnull', 'document_type__name__icontains', 'document_type__name__iendswith', 'document_type__name__iexact', 'document_type__name__istartswith', 'has_custom_fields', 'id', 'id__in', 'is_in_inbox', 'is_tagged', 'limit', 'original_filename__icontains', 'original_filename__iendswith', 'original_filename__iexact', 'original_filename__istartswith', 'owner__id', 'owner__id__in', 'owner__id__none', 'owner__isnull', 'shared_by__id', 'shared_by__id__in', 'storage_path__id', 'storage_path__id__in', 'storage_path__id__none', 'storage_path__isnull', 'storage_path__name__icontains', 'storage_path__name__iendswith', 'storage_path__name__iexact', 'storage_path__name__istartswith', 'tags__id', 'tags__id__all', 'tags__id__in', 'tags__id__none', 'tags__name__icontains', 'tags__name__iendswith', 'tags__name__iexact', 'tags__name__istartswith', 'title__icontains', 'title__iendswith', 'title__iexact', 'title__istartswith', 'title_content'}
- model: type[_Self]
- name: str
- property correspondent: Correspondent | None
Get the correspondent for this document.
- Returns:
The correspondent or None if not set.
Examples
>>> document = client.documents().get(pk=1) >>> document.correspondent.name 'Example Correspondent'
- custom_field_value(field_id, default=None, *, raise_errors=False)[source]
Get the value of a custom field by ID.
- property custom_fields: CustomFieldQuerySet
Get the custom fields for this document.
- Returns:
List of custom fields associated with this document.
- property document_type: DocumentType | None
Get the document type for this document.
- Returns:
The document type or None if not set.
Examples
>>> document = client.documents().get(pk=1) >>> document.document_type.name 'Example Document Type
- download(original=False)[source]
Download the document file.
- Parameters:
original (
bool) – Whether to download the original file instead of the archived version.- Return type:
- Returns:
The downloaded document.
Examples
>>> download = document.download() >>> with open(download.disposition_filename, 'wb') as f: ... f.write(download.content)
- get_metadata()[source]
Get the metadata for this document.
- Return type:
- Returns:
The document metadata.
Examples
>>> metadata = document.get_metadata() >>> print(metadata.original_mime_type)
- get_suggestions()[source]
Get suggestions for this document.
- Return type:
- Returns:
The document suggestions.
Examples
>>> suggestions = document.get_suggestions() >>> print(suggestions.tags)
- 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.
- preview(original=False)[source]
Get a preview of the document.
- Parameters:
original (
bool) – Whether to preview the original file instead of the archived version.- Return type:
- Returns:
The document preview.
- property storage_path: StoragePath | None
Get the storage path for this document.
- Returns:
The storage path or None if not set.
Examples
>>> document = client.documents().get(pk=1) >>> document.storage_path.name 'Example Storage Path'
- property tags: TagQuerySet
Get the tags for this document.
- Returns:
List of tags associated with this document.
Examples
>>> document = client.documents().get(pk=1) >>> for tag in document.tags: ... print(f'{tag.name} # {tag.id}') 'Tag 1 # 1' 'Tag 2 # 2' 'Tag 3 # 3'
>>> if 5 in document.tags: ... print('Tag ID #5 is associated with this document')
>>> tag = client.tags().get(pk=1) >>> if tag in document.tags: ... print('Tag ID #1 is associated with this document')
>>> filtered_tags = document.tags.filter(name__icontains='example') >>> for tag in filtered_tags: ... print(f'{tag.name} # {tag.id}')
- thumbnail(original=False)[source]
Get the document thumbnail.
- Parameters:
original (
bool) – Whether to get the thumbnail of the original file.- Return type:
- Returns:
The document thumbnail.
- update_locally(from_db=None, **kwargs)[source]
Update the document locally with the provided data.
- Parameters:
- Raises:
NotImplementedError – If attempting to set notes or tags to None when they are not already None.
- Return type:
- classmethod validate_custom_fields(value)[source]
Validate and return custom field dictionaries.
- Parameters:
value (
Any) – The list of custom field dictionaries to validate.- Return type:
- Returns:
A list of validated custom field dictionaries.
Validate and return the is_shared_by_requester flag.
- added: datetime | None
- archive_checksum: str | None
- archive_filename: str | None
- archive_serial_number: int | None
- archived_file_name: str | None
- checksum: str | None
- content: str
- correspondent_id: int | None
- created: datetime | None
- created_date: str | None
- custom_field_dicts: Annotated[list[CustomFieldValues], Field(default_factory=list)]
- deleted_at: datetime | None
- document_type_id: int | None
- filename: str | None
- is_shared_by_requester: bool
- notes: list[DocumentNote]
- original_filename: str | None
- owner: int | None
- page_count: int | None
- storage_path_id: int | None
- storage_type: DocumentStorageType | None
- tag_ids: Annotated[list[int], Field(default_factory=list)]
- title: str
- user_can_change: bool | None
- id: int
- class paperap.models.document.DocumentNote(**data)[source]
Bases:
StandardModelRepresents a note on a Paperless-NgX document.
- Parameters:
data (
Any)
- class Meta(model)[source]
Bases:
Meta- Parameters:
model (type[_Self])
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {}
- filtering_disabled: ClassVar[set[str]] = {}
- filtering_fields: ClassVar[set[str]] = {'_resource', 'created', 'deleted_at', 'document', 'id', 'note', 'restored_at', 'transaction_id', 'user'}
- read_only_fields: ClassVar[set[str]] = {'created', 'deleted_at', 'id', 'restored_at', 'transaction_id'}
- supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
- model: type[_Self]
- name: str
- get_document()[source]
Get the document associated with this note.
- Return type:
- Returns:
The document associated with this note.
- get_user()[source]
Get the user who created this note.
- Return type:
- Returns:
The user who created this note.
- 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.
- deleted_at: datetime | None
- restored_at: datetime | None
- transaction_id: int | None
- note: str
- created: datetime
- document: int
- user: int
- id: int
- class paperap.models.document.DocumentQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet[Document],HasOwnerQuerySet for Paperless-ngx documents with specialized filtering methods.
Examples
>>> # Search for documents >>> docs = client.documents().search("invoice") >>> for doc in docs: ... print(doc.title)
>>> # Find documents similar to a specific document >>> similar_docs = client.documents().more_like(42) >>> for doc in similar_docs: ... print(doc.title)
- Parameters:
resource (BaseResource[_Model, Self])
filters (dict[str, Any] | None)
_cache (list[_Model] | None)
_fetch_all (bool)
_next_url (str | None)
_last_response (ClientResponse)
_iter (Iterator[_Model] | None)
_urls_fetched (list[str] | None)
- add_tag(tag_id)[source]
Add a tag to all documents in the current queryset.
- Parameters:
tag_id (
int) – Tag ID to add- Return type:
Self- Returns:
Self for method chaining
Examples
>>> # Add tag 3 to all documents with "invoice" in title >>> client.documents().title("invoice", exact=False).add_tag(3)
- added_after(date_str)[source]
Filter documents added after the specified date.
- Parameters:
date_str (
str) – ISO format date string (YYYY-MM-DD)- Return type:
Self- Returns:
Filtered DocumentQuerySet
- added_before(date_str)[source]
Filter documents added before the specified date.
- Parameters:
date_str (
str) – ISO format date string (YYYY-MM-DD)- Return type:
Self- Returns:
Filtered DocumentQuerySet
- asn(value, *, exact=True, case_insensitive=True)[source]
Filter documents by archive serial number.
- content(text)[source]
Filter documents whose content contains the specified text.
- Parameters:
text (
str) – The text to search for in document content- Return type:
Self- Returns:
Filtered DocumentQuerySet
- correspondent(value=None, *, exact=True, case_insensitive=True, **kwargs)[source]
Filter documents by correspondent.
Any number of filter arguments can be provided, but at least one must be specified.
- Parameters:
- Return type:
Self- Returns:
Filtered DocumentQuerySet
- Raises:
ValueError – If no valid filters are provided
Examples
# Filter by ID client.documents().all().correspondent(1) client.documents().all().correspondent(id=1)
# Filter by name client.documents().all().correspondent(“John Doe”) client.documents().all().correspondent(name=”John Doe”)
# Filter by name (exact match) client.documents().all().correspondent(“John Doe”, exact=True) client.documents().all().correspondent(name=”John Doe”, exact=True)
# Filter by slug client.documents().all().correspondent(slug=”john-doe”)
# Filter by ID and name client.documents().all().correspondent(1, name=”John Doe”) client.documents().all().correspondent(id=1, name=”John Doe”) client.documents().all().correspondent(“John Doe”, id=1)
- Parameters:
case_insensitive (
bool)
- correspondent_id(correspondent_id)[source]
Filter documents by correspondent ID.
- Parameters:
correspondent_id (
int) – The correspondent ID to filter by- Return type:
Self- Returns:
Filtered DocumentQuerySet
- correspondent_name(name, *, exact=True, case_insensitive=True)[source]
Filter documents by correspondent name.
- correspondent_slug(slug, *, exact=True, case_insensitive=True)[source]
Filter documents by correspondent slug.
- custom_field(field, value, *, exact=False, case_insensitive=True)[source]
Filter documents by custom field.
- custom_field_contains(field, values)[source]
Filter documents with a custom field that contains all specified values.
- custom_field_exact(field, value)[source]
Filter documents with a custom field value that matches exactly.
- custom_field_exists(field, exists=True)[source]
Filter documents based on the existence of a custom field.
- custom_field_fullsearch(value, *, case_insensitive=True)[source]
Filter documents by searching through both custom field name and value.
- custom_field_in(field, values)[source]
Filter documents with a custom field value in a list of values.
- custom_field_isnull(field)[source]
Filter documents with a custom field that is null or empty.
- Parameters:
field (
str) – The name of the custom field- Return type:
Self- Returns:
Filtered DocumentQuerySet
- custom_field_range(field, start, end)[source]
Filter documents with a custom field value within a specified range.
- delete()[source]
Delete all documents in the current queryset.
- Return type:
TypeAliasType- Returns:
Self for method chaining
Examples
>>> # Delete all documents with "invoice" in title >>> client.documents().title("invoice", exact=False).delete()
- document_type(value=None, *, exact=True, case_insensitive=True, **kwargs)[source]
Filter documents by document type.
Any number of filter arguments can be provided, but at least one must be specified.
- Parameters:
- Return type:
Self- Returns:
Filtered DocumentQuerySet
- Raises:
ValueError – If no valid filters are provided
Examples
# Filter by ID client.documents().all().document_type(1) client.documents().all().document_type(id=1)
# Filter by name client.documents().all().document_type(“Invoice”) client.documents().all().document_type(name=”Invoice”)
# Filter by name (exact match) client.documents().all().document_type(“Invoice”, exact=True) client.documents().all().document_type(name=”Invoice”, exact=True)
# Filter by ID and name client.documents().all().document_type(1, name=”Invoice”) client.documents().all().document_type(id=1, name=”Invoice”) client.documents().all().document_type(“Invoice”, id=1)
- Parameters:
case_insensitive (
bool)
- document_type_id(document_type_id)[source]
Filter documents by document type ID.
- Parameters:
document_type_id (
int) – The document type ID to filter by- Return type:
Self- Returns:
Filtered DocumentQuerySet
- document_type_name(name, *, exact=True, case_insensitive=True)[source]
Filter documents by document type name.
- has_custom_field_id(pk, *, exact=False)[source]
Filter documents that have a custom field with the specified ID(s).
- merge(metadata_document_id=None, delete_originals=False)[source]
Merge all documents in the current queryset.
- Parameters:
- Return type:
- Returns:
True if submitting the merge succeeded, False if there are no ids to merge
- Raises:
BadResponseError – If the merge action returns an unexpected response
APIError – If the merge action fails
Examples
>>> # Merge all documents with tag "merge_me" >>> client.documents().tag_name("merge_me").merge(delete_originals=True)
- modify_custom_fields(add_custom_fields=None, remove_custom_fields=None)[source]
Modify custom fields on all documents in the current queryset.
- Parameters:
- Return type:
Self- Returns:
Self for method chaining
Examples
>>> # Add a custom field to documents with "invoice" in title >>> client.documents().title("invoice", exact=False).modify_custom_fields( ... add_custom_fields={5: "Processed"} ... )
- modify_tags(add_tags=None, remove_tags=None)[source]
Modify tags on all documents in the current queryset.
- Parameters:
- Return type:
Self- Returns:
Self for method chaining
Examples
>>> # Add tag 3 and remove tag 4 from all documents with "invoice" in title >>> client.documents().title("invoice", exact=False).modify_tags( ... add_tags=[3], remove_tags=[4] ... )
- more_like(document_id)[source]
Find documents similar to the specified document.
- Parameters:
document_id (
int) – The ID of the document to find similar documents for.- Return type:
- Returns:
A queryset with similar documents.
Examples
>>> similar_docs = client.documents().more_like(42) >>> for doc in similar_docs: ... print(doc.title)
- notes(text)[source]
Filter documents whose notes contain the specified text.
- Parameters:
text (
str) – The text to search for in document notes- Return type:
Self- Returns:
Filtered DocumentQuerySet
- original_filename(name, *, exact=True, case_insensitive=True)[source]
Filter documents by original file name.
- remove_tag(tag_id)[source]
Remove a tag from all documents in the current queryset.
- Parameters:
tag_id (
int) – Tag ID to remove- Return type:
Self- Returns:
Self for method chaining
Examples
>>> # Remove tag 4 from all documents with "invoice" in title >>> client.documents().title("invoice", exact=False).remove_tag(4)
- reprocess()[source]
Reprocess all documents in the current queryset.
- Return type:
TypeAliasType- Returns:
Self for method chaining
Examples
>>> # Reprocess documents added in the last week >>> from datetime import datetime, timedelta >>> week_ago = datetime.now() - timedelta(days=7) >>> client.documents().added_after(week_ago.strftime("%Y-%m-%d")).reprocess()
- rotate(degrees)[source]
Rotate all documents in the current queryset.
- Parameters:
degrees (
int) – Degrees to rotate (must be 90, 180, or 270)- Return type:
TypeAliasType- Returns:
Self for method chaining
Examples
>>> # Rotate all documents with "sideways" in title by 90 degrees >>> client.documents().title("sideways", exact=False).rotate(90)
- search(query)[source]
Search for documents using a query string.
- Parameters:
query (
str) – The search query.- Return type:
- Returns:
A queryset with the search results.
Examples
>>> docs = client.documents().search("invoice") >>> for doc in docs: ... print(doc.title)
- set_permissions(permissions=None, owner_id=None, merge=False)[source]
Set permissions for all documents in the current queryset.
- Parameters:
- Return type:
Self- Returns:
Self for method chaining
Examples
>>> # Set owner to user 2 for all documents with "invoice" in title >>> client.documents().title("invoice", exact=False).set_permissions(owner_id=2)
- storage_path(value=None, *, exact=True, case_insensitive=True, **kwargs)[source]
Filter documents by storage path.
Any number of filter arguments can be provided, but at least one must be specified.
- Parameters:
- Return type:
Self- Returns:
Filtered DocumentQuerySet
- Raises:
ValueError – If no valid filters are provided
Examples
# Filter by ID client.documents().all().storage_path(1) client.documents().all().storage_path(id=1)
# Filter by name client.documents().all().storage_path(“Invoices”) client.documents().all().storage_path(name=”Invoices”)
# Filter by name (exact match) client.documents().all().storage_path(“Invoices”, exact=True) client.documents().all().storage_path(name=”Invoices”, exact=True)
# Filter by ID and name client.documents().all().storage_path(1, name=”Invoices”) client.documents().all().storage_path(id=1, name=”Invoices”) client.documents().all().storage_path(“Invoices”, id=1)
- Parameters:
case_insensitive (
bool)
- storage_path_id(storage_path_id)[source]
Filter documents by storage path ID.
- Parameters:
storage_path_id (
int) – The storage path ID to filter by- Return type:
Self- Returns:
Filtered DocumentQuerySet
- storage_path_name(name, *, exact=True, case_insensitive=True)[source]
Filter documents by storage path name.
- tag_name(tag_name, *, exact=True, case_insensitive=True)[source]
Filter documents that have a tag with the specified name.
- update(*, correspondent=None, document_type=None, storage_path=None, owner=None)[source]
Perform bulk updates on all documents in the current queryset.
This method allows for multiple update operations in a single call.
- Parameters:
correspondent (
Correspondent|int|None) – Set correspondent for all documentsdocument_type (
DocumentType|int|None) – Set document type for all documentsstorage_path (
StoragePath|int|None) – Set storage path for all documents
- Return type:
Self- Returns:
Self for method chaining
- user_can_change(value)[source]
Filter documents by user change permission.
- Parameters:
value (
bool) – True to filter documents the user can change- Return type:
Self- Returns:
Filtered DocumentQuerySet
- resource: DocumentResource
- filters: dict[str, Any]
- class paperap.models.document.DocumentNoteQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet[DocumentNote]- Parameters:
resource (BaseResource[_Model, Self])
filters (dict[str, Any] | None)
_cache (list[_Model] | None)
_fetch_all (bool)
_next_url (str | None)
_last_response (ClientResponse)
_iter (Iterator[_Model] | None)
_urls_fetched (list[str] | None)
- class paperap.models.document.DownloadedDocument(**data)[source]
Bases:
StandardModelRepresents a downloaded Paperless-NgX document file.
- mode
The retrieval mode (download, preview, thumbnail).
- original
Whether to retrieve the original file.
- content
The binary content of the file.
- content_type
The MIME type of the file.
- disposition_filename
The filename from the Content-Disposition header.
- disposition_type
The type from the Content-Disposition header.
- Parameters:
data (
Any)
- class Meta(model)[source]
Bases:
Meta- Parameters:
model (type[_Self])
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {}
- filtering_disabled: ClassVar[set[str]] = {}
- filtering_fields: ClassVar[set[str]] = {'_resource', 'content', 'content_type', 'disposition_filename', 'disposition_type', 'id', 'mode', 'original'}
- read_only_fields: ClassVar[set[str]] = {'content', 'content_type', 'disposition_filename', 'disposition_type', 'id'}
- supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
- 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.
- mode: RetrieveFileMode | None
- original: bool
- content: bytes | None
- content_type: str | None
- disposition_filename: str | None
- disposition_type: str | None
- class paperap.models.document.DownloadedDocumentQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet[DownloadedDocument]- Parameters:
resource (BaseResource[_Model, Self])
filters (dict[str, Any] | None)
_cache (list[_Model] | None)
_fetch_all (bool)
_next_url (str | None)
_last_response (ClientResponse)
_iter (Iterator[_Model] | None)
_urls_fetched (list[str] | None)
- class paperap.models.document.DocumentMetadata(**data)[source]
Bases:
StandardModelRepresents a Paperless-NgX document’s metadata.
- original_checksum
The checksum of the original document.
- original_size
The size of the original document in bytes.
- original_mime_type
The MIME type of the original document.
- media_filename
The filename of the media file.
- has_archive_version
Whether the document has an archive version.
- original_metadata
Metadata of the original document.
- archive_checksum
The checksum of the archived document.
- archive_media_filename
The filename of the archived media file.
- original_filename
The original filename of the document.
- lang
The language of the document.
- archive_size
The size of the archived document in bytes.
- archive_metadata
Metadata of the archived document.
- Parameters:
data (
Any)
- class Meta(model)[source]
Bases:
Meta- Parameters:
model (type[_Self])
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {}
- filtering_disabled: ClassVar[set[str]] = {}
- filtering_fields: ClassVar[set[str]] = {'_resource', 'archive_checksum', 'archive_media_filename', 'archive_metadata', 'archive_size', 'has_archive_version', 'id', 'lang', 'media_filename', 'original_checksum', 'original_filename', 'original_metadata', 'original_mime_type', 'original_size'}
- read_only_fields: ClassVar[set[str]] = {'archive_checksum', 'archive_media_filename', 'archive_metadata', 'archive_size', 'has_archive_version', 'id', 'lang', 'media_filename', 'original_checksum', 'original_filename', 'original_metadata', 'original_mime_type', 'original_size'}
- supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
- 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.
- original_checksum: str | None
- original_size: int | None
- original_mime_type: str | None
- media_filename: str | None
- has_archive_version: bool | None
- original_metadata: list[MetadataElement]
- archive_checksum: str | None
- archive_media_filename: str | None
- original_filename: str | None
- lang: str | None
- archive_size: int | None
- archive_metadata: list[MetadataElement]
- class paperap.models.document.DocumentMetadataQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet[DocumentMetadata]- Parameters:
resource (BaseResource[_Model, Self])
filters (dict[str, Any] | None)
_cache (list[_Model] | None)
_fetch_all (bool)
_next_url (str | None)
_last_response (ClientResponse)
_iter (Iterator[_Model] | None)
_urls_fetched (list[str] | None)
- class paperap.models.document.MetadataElement(**data)[source]
Bases:
BaseModelRepresents metadata for a document in Paperless-NgX.
This is a key-value pair of metadata information.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- key: str
- value: str
- class paperap.models.document.CustomFieldValues(**data)[source]
Bases:
ConstModel- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'from_attributes': 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].
- field: int
- value: Any
- class paperap.models.document.DocumentSuggestions(**data)[source]
Bases:
StandardModelRepresents suggestions for a Paperless-NgX document.
- correspondents
List of suggested correspondent IDs.
- tags
List of suggested tag IDs.
- document_types
List of suggested document type IDs.
- storage_paths
List of suggested storage path IDs.
- dates
List of suggested dates.
- Parameters:
data (
Any)
- class Meta(model)[source]
Bases:
Meta- Parameters:
model (type[_Self])
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {}
- filtering_disabled: ClassVar[set[str]] = {}
- filtering_fields: ClassVar[set[str]] = {'_resource', 'correspondents', 'dates', 'document_types', 'id', 'storage_paths', 'tags'}
- read_only_fields: ClassVar[set[str]] = {'correspondents', 'dates', 'document_types', 'id', 'storage_paths', 'tags'}
- supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
- 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.
- correspondents: list[int]
- tags: list[int]
- document_types: list[int]
- storage_paths: list[int]
- dates: list[date]
- class paperap.models.document.DocumentSuggestionsQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet[DocumentSuggestions]- Parameters:
resource (BaseResource[_Model, Self])
filters (dict[str, Any] | None)
_cache (list[_Model] | None)
_fetch_all (bool)
_next_url (str | None)
_last_response (ClientResponse)
_iter (Iterator[_Model] | None)
_urls_fetched (list[str] | None)
Subpackages
Submodules
- paperap.models.document.meta module
- paperap.models.document.model module
DocumentNoteDocumentNote.deleted_atDocumentNote.restored_atDocumentNote.transaction_idDocumentNote.noteDocumentNote.createdDocumentNote.documentDocumentNote.userDocumentNote.MetaDocumentNote.serialize_datetime()DocumentNote.get_document()DocumentNote.get_user()DocumentNote.model_configDocumentNote.model_post_init()DocumentNote.id
DocumentDocument.addedDocument.archive_serial_numberDocument.archived_file_nameDocument.contentDocument.correspondentDocument.createdDocument.created_dateDocument.updatedDocument.custom_fieldsDocument.deleted_atDocument.document_typeDocument.is_shared_by_requesterDocument.notesDocument.original_filenameDocument.ownerDocument.page_countDocument.storage_pathDocument.tagsDocument.titleDocument.user_can_changeDocument.checksumDocument.addedDocument.archive_checksumDocument.archive_filenameDocument.archive_serial_numberDocument.archived_file_nameDocument.checksumDocument.contentDocument.correspondent_idDocument.createdDocument.created_dateDocument.custom_field_dictsDocument.deleted_atDocument.document_type_idDocument.filenameDocument.is_shared_by_requesterDocument.notesDocument.original_filenameDocument.ownerDocument.page_countDocument.storage_path_idDocument.storage_typeDocument.tag_idsDocument.titleDocument.user_can_changeDocument.MetaDocument.serialize_datetime()Document.serialize_notes()Document.validate_tags()Document.validate_custom_fields()Document.validate_text()Document.validate_notes()Document.validate_is_shared_by_requester()Document.custom_field_idsDocument.custom_field_valuesDocument.tag_namesDocument.tagsDocument.correspondentDocument.document_typeDocument.storage_pathDocument.custom_fieldsDocument.has_search_hitDocument.search_hitDocument.custom_field_value()Document.add_tag()Document.remove_tag()Document.get_metadata()Document.download()Document.model_configDocument.model_post_init()Document.preview()Document.idDocument.thumbnail()Document.get_suggestions()Document.append_content()Document.update_locally()
- paperap.models.document.queryset module
CustomFieldQueryDocumentNoteQuerySetDocumentQuerySetDocumentQuerySet.resourceDocumentQuerySet.tag_id()DocumentQuerySet.tag_name()DocumentQuerySet.title()DocumentQuerySet.search()DocumentQuerySet.more_like()DocumentQuerySet.correspondent()DocumentQuerySet.correspondent_id()DocumentQuerySet.correspondent_name()DocumentQuerySet.correspondent_slug()DocumentQuerySet.document_type()DocumentQuerySet.document_type_id()DocumentQuerySet.document_type_name()DocumentQuerySet.storage_path()DocumentQuerySet.storage_path_id()DocumentQuerySet.storage_path_name()DocumentQuerySet.content()DocumentQuerySet.added_after()DocumentQuerySet.added_before()DocumentQuerySet.asn()DocumentQuerySet.original_filename()DocumentQuerySet.user_can_change()DocumentQuerySet.custom_field_fullsearch()DocumentQuerySet.custom_field()DocumentQuerySet.has_custom_field_id()DocumentQuerySet.custom_field_query()DocumentQuerySet.custom_field_range()DocumentQuerySet.custom_field_exact()DocumentQuerySet.custom_field_in()DocumentQuerySet.custom_field_isnull()DocumentQuerySet.custom_field_exists()DocumentQuerySet.custom_field_contains()DocumentQuerySet.has_custom_fields()DocumentQuerySet.no_custom_fields()DocumentQuerySet.notes()DocumentQuerySet.created_before()DocumentQuerySet.created_after()DocumentQuerySet.created_between()DocumentQuerySet.delete()DocumentQuerySet.reprocess()DocumentQuerySet.merge()DocumentQuerySet.rotate()DocumentQuerySet.update()DocumentQuerySet.modify_custom_fields()DocumentQuerySet.modify_tags()DocumentQuerySet.add_tag()DocumentQuerySet.filtersDocumentQuerySet.remove_tag()DocumentQuerySet.set_permissions()