Installation

Install the library

django-twined is available on pypi, so installation into your python virtual environment is dead simple:

poetry add django-twined

Not using poetry yet? You definitely should, there’s a small learning curve then it removes a world of pip agony :)

Install the django app

You’ll need to install django_twined, django_gcp and jsoneditor as apps in your django settings:

INSTALLED_APPS = [
    # ...
    'django_gcp',  # For event handlers and flexible storages
    'django_twined',
    'jsoneditor',  # For editing JSON in modeladmin views
    # ...
]

Tip

You can use django-gcp for your media/static storage, event handlers and task queues too!

Add the services endpoint

Include the django-twined URLs in your your_app/urls.py:

from django.urls import include, re_path

urlpatterns = [
   # ...other routes
   # Use whatever regex you want:
   re_path(r"^integrations/octue/", include("django_twined.urls")),
]

Using python manage.py show_urls you can now see the endpoint for registering and getting service revisions appear in your app.

Warning

The registry URLs are CSRF-exempt by default to allow automatic service revision registration from, for example, GitHub Actions. If you don’t want this behaviour, you can import the view at django_twined.views.service_revision and use it in your URL patterns as you like.

Run migrations

Then run python manage.py migrate django_twined to add the models used for managing services, events and questions to your database.

Add the base URL

Finally, make sure the BASE_URL setting is present in settings.py - it’s used to create absolute URLs for webhooks.

BASE_URL = "https://your-server.com"