paperap.models.storage_path.model module
Define the StoragePath model for managing document storage locations in Paperless-NgX.
This module provides the StoragePath model class, which represents physical storage locations where documents are stored in the Paperless-NgX file system. Storage paths allow for organizing documents into different directories based on document type, date, or other criteria.
- class paperap.models.storage_path.model.StoragePath(**data)[source]
Bases:
StandardModel
,MatcherMixin
Represent a storage path in Paperless-NgX.
A storage path defines where documents are physically stored in the Paperless-NgX file system. Each document can be assigned to a specific storage path, allowing for organized file storage based on document type, date, or other criteria.
Storage paths can also be configured with matching rules to automatically assign documents to specific paths based on their content or metadata.
- name
The display name of the storage path.
- slug
The URL-friendly version of the name (auto-generated, read-only).
- path
The actual filesystem path where documents will be stored.
- document_count
The number of documents using this storage path (read-only).
- owner
The ID of the user who owns this storage path, if applicable.
- user_can_change
Whether the current user has permission to modify this path.
Examples
- Create a new storage path:
>>> tax_path = client.storage_paths.create( ... name="Tax Documents", ... path="/documents/taxes/" ... )
- Assign a storage path to a document:
>>> doc = client.documents.get(123) >>> doc.storage_path = tax_path.id >>> doc.save()
- Create a storage path with automatic matching:
>>> invoice_path = client.storage_paths.create( ... name="Invoices", ... path="/documents/invoices/", ... matching_algorithm="auto", ... match="invoice bill receipt" ... )
- Parameters:
data (
Any
)
- name: str
- slug: str | None
- path: str | None
- document_count: int
- owner: int | None
- user_can_change: bool | None
- class Meta(model)[source]
Bases:
Meta
Define metadata for the StoragePath model.
This class defines metadata properties that control how the StoragePath model interacts with the Paperless-NgX API, including which fields are read-only and which QuerySet class to use for queries.
- read_only_fields
Set of field names that cannot be modified by the client.
- 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
StoragePathQuerySet
- 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', 'path', '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 assigned to this storage path.
Retrieve a queryset containing all documents that use this storage path. The queryset is lazy-loaded, meaning API requests are only made when the results are actually needed (when iterating, slicing, or calling terminal methods like count() or get()).
- Returns:
- A queryset containing all documents that use this
storage path. The queryset can be further filtered or ordered.
- Return type:
Examples
- Get all documents in a storage path:
>>> tax_path = client.storage_paths.get(5) >>> tax_docs = tax_path.documents >>> print(f"Found {tax_docs.count()} tax documents")
- Filter documents in a storage path:
>>> recent_tax_docs = tax_path.documents.filter( ... created__gt="2023-01-01" ... ) >>> for doc in recent_tax_docs: ... print(f"{doc.title} - {doc.created}")
- 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.
- id: int