Skip to main content

Easily integrate Open Forms in your Django application.

Project description

Open Forms Client (for Django)





Open Forms, Client, Django



Build status Code quality checks black Coverage status

python-versions django-versions pypi-version


Easily integrate Open Forms in your Django application. There are 3 main features:

  1. Configuration to connect to Open Forms is added to your Django admin.

  2. By adding an OpenFormsField in any Django model, you get a list of forms in Open Forms to choose from in the Django admin or other Django forms.

  3. You get templatetags to render an Open Forms form in your webpage.

If you have Sentry installed and you enable Sentry in the Django admin configuration page, it will use your existing configuration to connect to Sentry.

Ordered dashboard with dropdown menu. Ordered dashboard with dropdown menu. Ordered dashboard with dropdown menu.



  • Python 3.7 or newer

  • Django 3.2 or newer


You can install Open Forms Client either via the Python Package Index (PyPI) or from source.

To install using pip:

pip install django-open-forms-client


To use this with your project you need to follow these steps:

  1. Add open_forms_client to INSTALLED_APPS in your Django project’s

        # ...,

    Note that there are no dashes in the module name, only underscores.

  2. Add an OpenFormsField to your relevant models (like a Page model):

    class Page(models.Model):
        # ...
        form = OpenFormsField(blank=True)
  3. Add the templatetags {% openforms_sdk_media %} and {% openforms_form page.form %} to your templates, to render an Open Forms form:

    {% load openforms %}
    <!-- Optional to render Open Forms in the proper language -->
    <html lang="nl">
        <!-- Required for icons used by Open Forms -->
        <meta charset="utf-8">
        {% openforms_sdk_media %}
    {% if page.form %}
        {% openforms_form page.form %}
    {% else %}
        <p>This page has no form</p>
    {% endif %}
  4. Configure your Open Forms connection and settings in the admin, under Open Forms client configuration. Once the status field shows a green icon, your configuration is working.

  5. Done.


There are 4 templatetags available with several parameters. All parameters translate to Open Forms SDK parameters.

openforms_form(form_id, csp_nonce=None, base_path=None, lang=None, html_id=None)


Open Forms configuration

Make sure the domain where you host your webapplication is in the Open Forms ALLOWED_HOSTS setting. Note that this is not the setting in your own webapplication but in the setting in the Open Forms installation.

CPS headers

When your webapplication uses CSP headers you need to pass the csp_nonce to the openforms_form templatetag as well. If you use Django-CSP you can do this:

{% load openforms %}
{% openforms_form page.form csp_nonce=csp_nonce=request.csp_nonce %}

Additionally, you need to allow your webapplication to load styles and scripts from the Open Forms SDK and connect to the Open Forms API. When using Django-CSP some options need to be changed in your

# The Open Forms SDK files might differ from the API domain.

# Allow your webapp to load styles from Open Forms SDK.

# Allow your webapp to load script from Open Forms SDK.

# Allow your webapp to load images from Open Forms SDK.

# Allow your webapp to load fonts from Open Forms SDK.

# Allow your webapp to connect to the Open Forms API.

Make page refreshes work

The URL changes when you start a form, indicating the step you are currently on. Refreshing the page will result in a HTTP 404 because this URL does not actually exist. You need to catch these URL-patterns and redirect the user back to the form. You can so like this:


# The view thats starts the form
path("page/<slug:slug>", PageView.as_view(), name="page"),
# Whenever you refresh the page that has the form, the URL might be changed
# and needs to redirect the user to the start of the form.
re_path("^page/(?P<slug>\w+)/", FormRedirectView.as_view()),


Copyright © Maykin Media B.V., 2022

Licensed under the MIT.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-open-forms-client-0.1.0.tar.gz (9.9 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page