# django-ogcapif
**WARNING** This is in under development. API will break. Do not use in production.
*django-ogcapif* allows to easily expose your Django models through an OGCAPI-Features endpoint. It is based on Django REST Framework.
## Quickstart
```bash
# copy default conf
cp .env.example .env
# start the stack
docker compose up --build -d
# deploy static files and migrate database
docker compose exec django python manage.py collectstatic --no-input
docker compose exec django python manage.py migrate --no-input
# A convenience start-up Django command is there to populate the database with testdata for each app:
docker compose exec django python manage.py populate_vl
docker compose exec django python manage.py populate_signs_poles
docker compose exec django python manage.py populate_edge_cases
# Wait a little, then check that https://localhost/oapif/collections/signalo_core.pole/items works from your browser
```
## Tests
To run all tests, launch the Compose application as shown in the [Quickstart](#quickstart). Then run
docker compose exec django python manage.py test
## Authentication & permissions
By default the viewsets under `signalo/core` use the `DjangoModelPermissionsOrAnonReadOnly` permissions class. You can add model permissions when registering their corresponding viewsets, as `permission_classes`. (Refer to https://www.django-rest-framework.org/api-guide/permissions/#api-reference for permission classes). Example:
```python
# models.py
# ----------
from rest_framework import permissions
from django.contrib.gis.db import models
from django_oapif.decorators import register_oapif_viewset
@register_oapif_viewset(
custom_viewset_attrs={
"permission_classes": (permissions.DjangoModelPermissionsOrAnonReadOnly,)
}
)
class MyModel(models.Model):
...
```
## Use from QGIS
Once up and running, you can use it from QGIS like this:
- Go to `Layers` > `Add layer` > `Add WFS Layer...`
- Create a new connection
- URL: `https://localhost/oapif/`
- Version: `OGC API - Features`
- Click OK and ignore choose to ignore the invalid certificate error and store the exception
- You should see the two layers in the list, select them and choose `add`.
## Run tests
You can run the OGC API conformance test suite like this:
```
docker compose run conformance_test
```
Results will be stored to `_test_outputs\testng\...\emailable-report.html
Raw data
{
"_id": null,
"home_page": "",
"name": "django-ogcapif",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "django,ogc,api,wfs3,features,rest,gis,ogcapif",
"author": "",
"author_email": "\"OPENGIS.ch\" <info@opengis.ch>",
"download_url": "https://files.pythonhosted.org/packages/c1/ed/56994fda58fe848cdfe9d60eb81a928cccca78c9e4bb427517f2db430d3b/django-ogcapif-0.1.6.tar.gz",
"platform": null,
"description": "# django-ogcapif\n\n**WARNING** This is in under development. API will break. Do not use in production.\n\n*django-ogcapif* allows to easily expose your Django models through an OGCAPI-Features endpoint. It is based on Django REST Framework.\n\n\n## Quickstart\n\n```bash\n# copy default conf\ncp .env.example .env\n\n# start the stack\ndocker compose up --build -d\n\n# deploy static files and migrate database\ndocker compose exec django python manage.py collectstatic --no-input\ndocker compose exec django python manage.py migrate --no-input\n\n# A convenience start-up Django command is there to populate the database with testdata for each app:\ndocker compose exec django python manage.py populate_vl\ndocker compose exec django python manage.py populate_signs_poles\ndocker compose exec django python manage.py populate_edge_cases\n\n# Wait a little, then check that https://localhost/oapif/collections/signalo_core.pole/items works from your browser\n```\n\n## Tests\n\nTo run all tests, launch the Compose application as shown in the [Quickstart](#quickstart). Then run\n\n docker compose exec django python manage.py test\n\n## Authentication & permissions\n\nBy default the viewsets under `signalo/core` use the `DjangoModelPermissionsOrAnonReadOnly` permissions class. You can add model permissions when registering their corresponding viewsets, as `permission_classes`. (Refer to https://www.django-rest-framework.org/api-guide/permissions/#api-reference for permission classes). Example:\n\n```python\n# models.py\n# ----------\nfrom rest_framework import permissions\nfrom django.contrib.gis.db import models\nfrom django_oapif.decorators import register_oapif_viewset\n\n@register_oapif_viewset(\n custom_viewset_attrs={\n \"permission_classes\": (permissions.DjangoModelPermissionsOrAnonReadOnly,)\n }\n)\nclass MyModel(models.Model):\n ...\n```\n\n## Use from QGIS\n\nOnce up and running, you can use it from QGIS like this:\n\n- Go to `Layers` > `Add layer` > `Add WFS Layer...`\n- Create a new connection\n - URL: `https://localhost/oapif/`\n - Version: `OGC API - Features`\n- Click OK and ignore choose to ignore the invalid certificate error and store the exception\n- You should see the two layers in the list, select them and choose `add`.\n\n## Run tests\n\nYou can run the OGC API conformance test suite like this:\n\n```\ndocker compose run conformance_test\n```\n\nResults will be stored to `_test_outputs\\testng\\...\\emailable-report.html\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Easily expose your Django models through an OGCAPI-Features endpoint",
"version": "0.1.6",
"project_urls": {
"homepage": "https://github.com/opengisch/django-ogcapif",
"repository": "https://github.com/opengisch/django-ogcapif",
"tracker": "https://github.com/opengisch/django-ogcapif/issues"
},
"split_keywords": [
"django",
"ogc",
"api",
"wfs3",
"features",
"rest",
"gis",
"ogcapif"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bfc4fe30dc14288c760b591e1e7cc372635451a6af1aade9ecf949c3562645c2",
"md5": "93071a257aef7152d6f1882afbbe13ba",
"sha256": "4c377b842131fba6664ad4351664c18442814235a482822fc1cb2a3d9f96999b"
},
"downloads": -1,
"filename": "django_ogcapif-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "93071a257aef7152d6f1882afbbe13ba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11775,
"upload_time": "2023-05-09T08:43:25",
"upload_time_iso_8601": "2023-05-09T08:43:25.747545Z",
"url": "https://files.pythonhosted.org/packages/bf/c4/fe30dc14288c760b591e1e7cc372635451a6af1aade9ecf949c3562645c2/django_ogcapif-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c1ed56994fda58fe848cdfe9d60eb81a928cccca78c9e4bb427517f2db430d3b",
"md5": "e8a2eea656a9a0dd7b7d092c295c5f3f",
"sha256": "0e6fa7f97bcc229eecf4a9ecf1ae96b9f229d6779c94d612e1ce38fddd32bbe4"
},
"downloads": -1,
"filename": "django-ogcapif-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "e8a2eea656a9a0dd7b7d092c295c5f3f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10723,
"upload_time": "2023-05-09T08:43:27",
"upload_time_iso_8601": "2023-05-09T08:43:27.464421Z",
"url": "https://files.pythonhosted.org/packages/c1/ed/56994fda58fe848cdfe9d60eb81a928cccca78c9e4bb427517f2db430d3b/django-ogcapif-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-09 08:43:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "opengisch",
"github_project": "django-ogcapif",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "django",
"specs": [
[
">=",
"4"
]
]
},
{
"name": "django-computedfields",
"specs": []
},
{
"name": "psycopg2",
"specs": []
},
{
"name": "transifex-client",
"specs": []
},
{
"name": "djangorestframework",
"specs": []
},
{
"name": "djangorestframework-gis",
"specs": []
},
{
"name": "pyyaml",
"specs": []
},
{
"name": "uritemplate",
"specs": []
},
{
"name": "pyproj",
"specs": []
}
],
"lcname": "django-ogcapif"
}