paperap.models.custom_field.queryset module
Provide specialized queryset for custom fields in Paperless-ngx.
This module implements the CustomFieldQuerySet class, which extends the standard queryset functionality with methods specific to custom fields. It enables filtering by name, data type, and extra data properties.
- class paperap.models.custom_field.queryset.CustomFieldQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]
Bases:
StandardQuerySet
[CustomField],HasDocumentCount
Manage and filter custom fields from Paperless-ngx.
Extends StandardQuerySet to provide specialized filtering methods for custom fields. Allows filtering by name, data type, and extra data, making it easier to find and manage custom fields.
The QuerySet is lazy-loaded, meaning API requests are only made when the results are actually needed (when iterating, counting, etc.).
- Inherits all attributes from StandardQuerySet and HasDocumentCount.
Examples
- Get all string-type custom fields:
>>> string_fields = client.custom_fields().data_type("string")
- Find custom fields with a specific name pattern:
>>> invoice_fields = client.custom_fields().name("invoice", exact=False)
- 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)
- name(value, *, exact=True, case_insensitive=True)[source]
Filter custom fields by name.
Filter the queryset to include only custom fields whose names match the specified value, with options for exact matching and case sensitivity.
- Parameters:
- Return type:
Self
- Returns:
A filtered CustomFieldQuerySet containing only matching custom fields.
Examples
- Find fields with exact name “Invoice Number”:
>>> invoice_fields = client.custom_fields().name("Invoice Number")
- Find fields containing “date” (case-insensitive):
>>> date_fields = client.custom_fields().name("date", exact=False)
- data_type(value, *, exact=True, case_insensitive=True)[source]
Filter custom fields by data type.
Filter the queryset to include only custom fields with the specified data type. Paperless-ngx supports several data types for custom fields, including string, integer, boolean, date, etc.
- Parameters:
- Return type:
Self
- Returns:
A filtered CustomFieldQuerySet containing only custom fields with matching data types.
Examples
- Get all date-type custom fields:
>>> date_fields = client.custom_fields().data_type("date")
- Get all numeric fields (integer or float):
>>> numeric_fields = client.custom_fields().data_type("int", exact=False)
- extra_data(key, value)[source]
Filter custom fields by a key-value pair in extra_data.
Filter custom fields based on specific values within the extra_data JSON structure. Custom fields in Paperless-ngx can have additional configuration stored in this extra_data field.
- Parameters:
- Return type:
Self
- Returns:
A filtered CustomFieldQuerySet containing only custom fields with matching extra_data values.
Examples
- Find custom fields with specific configuration:
>>> fields = client.custom_fields().extra_data("format", "currency")
- Find fields with nested configuration:
>>> fields = client.custom_fields().extra_data("options__default", True)