API documentation¶
django_oapif.api.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()])
register ¶
register(model_class: type [Model ], /, id: str | None = None, title: str | None = None, description: str | None = None, geometry_field: str | None = 'geom', properties_fields: list [str ] | None = None, handler: type [QueryHandler ] = DjangoModelPermissionsOrAnonReadOnly ) -> None
Register a model to expose as an OGC API Features collection.
Parameters:
-
id(, default:str | NoneNone) –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(, default:str | NoneNone) –The collection title. If not defined, will be set to
model_class._meta.label. -
description(, default:str | NoneNone) –The collection description.
-
geometry_field(, default:str | None'geom') –The collection geometry field. Must be set to
Nonefor collections without a geometry. -
properties_fields(, default:list [str ] | NoneNone) –The list of fields that will be exposed as feature properties. If not defined, all fields will be used.
django_oapif.handler ¶
QueryHandler ¶
Base class used to customize authorization and model operations.
delete_model ¶
Given a model instance delete it from the database.
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.
has_view_permission ¶
Returns True if the given request has permission to view objects in the collection, or a given object if defined.
save_model ¶
Given a model instance save it to the database.
IsAuthenticated ¶
Bases:
Allows full access to authenticated users only.
IsAuthenticatedOrReadOnly ¶
Bases:
Allows full access to authenticated users only, but allows readonly access to everyone.
DjangoModelPermissions ¶
Bases:
Reuses all Django permissions for a given model.
DjangoModelPermissionsOrAnonReadOnly ¶
Bases:
Reuses all Django permissions for a given model, but allows readonly access to everyone.