API documentation¶
django_oapif ¶
OAPIF ¶
OAPIF(*, title: str = 'OAPIF', version: str = version ('django-oapif'), description: str = '', docs: DocsBase = Swagger (), docs_url: str | None = '/docs', docs_decorator: Callable [[TCallable ], TCallable ] | None = None, servers: list [DictStrAny ] | None = None, urls_namespace: str | None = None, auth: Sequence [Callable ] | Callable | NOT_SET_TYPE | None = NOT_SET , throttle: BaseThrottle | list [BaseThrottle ] | NOT_SET_TYPE = NOT_SET , renderer: BaseRenderer | None = None, parser: Parser | None = None, default_router: Router | None = None, openapi_extra: dict [str , Any ] | None = None)
The OAPIF class wraps a Ninja API that will expose the OGC API Features endpoints.
The parameters will be passed to the NinjaApi constructor.
By default auth will be set to use the same authentication method as Django, but
it may be configured differently (see Ninja authentication documentation).
Django OAPIF also provides a utility to use HTTP Basic Auth as an authentication method.
Examples:
>>> from django_oapif import OAPIF
>>> from django_oapif.auth import BasicAuth, DjangoAuth
>>>
>>> api = OAPIF(auth=[BasicAuth(), DjangoAuth()])
OapifCollection ¶
Base class used to customize authorization and model operations.
Attributes:
-
(id ) –str The collection identifier when calling the API, eg:
https://example.com/oapif/collections/<id>/items. If not defined, will be set tomodel_class._meta.label_lower. -
(title ) –str The collection title. If not defined, will be set to
model_class._meta.label. -
(description ) –str | NoneThe collection description.
-
(geometry_field ) –str | NoneThe collection geometry field. If not defined, the geometry field will be infered from the model.
-
(fields ) –tuple [str , ...]The list of fields that will be exposed as feature properties. If not defined, all fields will be used.
-
(readonly_fields ) –tuple [str , ...]The list of fields that will be included in the feature properties, but won't be accepted in Create/Update operations.
-
(exclude ) –tuple [str , ...]The list of fields to be excluded from the feature properties.exclude:
-
–ordering The field used to sort the queryset.
get_readonly_fields ¶
Hook for specifying custom readonly fields.
save_model ¶
Given a model instance save it to the database.
delete_model ¶
Given a model instance delete it from the database.
has_view_permission ¶
Returns True if the given request has permission to view objects in the collection, or a given object if defined.
has_add_permission ¶
Returns True if the given request has permission to create objects in the collection, or a given object if defined.
has_change_permission ¶
Returns True if the given request has permission to change objects in the collection, or a given object if defined.
has_delete_permission ¶
Returns True if the given request has permission to delete objects in the collection, or a given object if defined.
AllowAnyCollection ¶
Bases:
Allows full access to everyone.
AuthenticatedCollection ¶
Bases:
Allows full access to authenticated users only.
AuthenticatedOrReadOnlyCollection ¶
Bases:
Allows full access to authenticated users only, but allows readonly access to everyone.
AnonReadOnlyCollection ¶
Bases:
Reuses all Django permissions for a given model, but allows readonly access to everyone.