rest
django_spire.contrib.rest
__all__ = ['BaseRestHttpConnector', 'DjangoModelRestSchema', 'RestSchema', 'RestSchemaSet']
module-attribute
RestSchema
Bases: ABC, BaseModel
Base class for REST API schemas that should map to django models with Django-like .objects API.
Provides a Django QuerySet - like interface for interacting with external REST-based data sources.
Subclasses need to assign an instance of a RestSchemaSet subclass to the objects class: objects = MySchemaSet
objects
class-attribute
__pydantic_init_subclass__
classmethod
Source code in django_spire/contrib/rest/schema/schema.py
RestSchemaSet
Source code in django_spire/contrib/rest/schema/schemaset.py
connector
instance-attribute
schema_class = schema_class
instance-attribute
as_manager
classmethod
Simply returns an instance of itself with no schema class. Provides no real value other than a more Django model-like objects assignment in RestSchema classes.
Source code in django_spire/contrib/rest/schema/schemaset.py
__iter__
__len__
__bool__
__repr__
__getitem__
Source code in django_spire/contrib/rest/schema/schemaset.py
with_request_params
Set or merge request parameters for downstream API calls.
Source code in django_spire/contrib/rest/schema/schemaset.py
all
filter
Filter results by predicate and/or field lookups.
Examples: .filter(lambda p: p.weight > 100) .filter(name="pikachu") .filter(type__name="electric")
Source code in django_spire/contrib/rest/schema/schemaset.py
exclude
Exclude results matching predicate or field lookups.
Source code in django_spire/contrib/rest/schema/schemaset.py
order_by
Order by fields. Prefix with '-' for descending.
Examples: .order_by('name') .order_by('-weight', 'name')
Source code in django_spire/contrib/rest/schema/schemaset.py
limit
offset
first
last
count
exists
get
Return exactly one result matching kwargs. Raises LookupError if zero or multiple results.
Source code in django_spire/contrib/rest/schema/schemaset.py
values_list
Extract field values from results.
Source code in django_spire/contrib/rest/schema/schemaset.py
DjangoModelRestSchema
Bases: RestSchema, Generic[TModel], ABC
from_django_model
abstractmethod
classmethod
BaseRestHttpConnector
Bases: ABC