Skip to content

Quickstart

Installation

Install with your favorite package manager

pip install --user https://github.com/opengisch/django-oapif

Enable the app

Edit settings.py

INSTALLED_APPS = [
    ...
    "django_oapif",
    "rest_framework",
    "rest_framework_gis",
]

Add this to your urls.py :

urlpatterns += [ ..., path("oapif/", include(django_oapif.urls)), ..., ]

Register your models with the decorator:

# models.py

from django.contrib.gis.db import models
from django_oapif.decorators import register_oapif_viewset


@register_oapif_viewset()
class TestingDecorator(models.Model):
    name = models.CharField(max_length=10)
    geom = models.PointField(srid=2056)

Configure global settings

Optionally specify your endpoint's metadata in settings.py:

# settings.py
...

OAPIF_TITLE = "My Endpoint"
OAPIF_DESCRIPTION = "Description"

VoilĂ  ! Your OAPIF endpoint should be ready to use.