Skip to main content

Django application for handling privacy and cookie policies configured with Iubenda.

Project description

django-iubenda PyPi license

PyPi status PyPi version PyPi python version PyPi downloads PyPi downloads PyPi downloads

GitHub GitHub release GitHub release

Test codecov.io pre-commit.ci status gitthub.com

Compliance for websites and apps

Click here and get 10% discount on first year at Iubenda Iubenda

Check Demo Project

  • Browser the demo app on-line on Heroku
  • Check the demo repo on GitHub

Requirements

  • Python 3.7 to 3.10 supported.
  • Django 3.2 to 4.0 supported.

Setup

  1. Install from pip:
pip install django-iubenda
  1. Modify settings.py by adding the app to INSTALLED_APPS:
INSTALLED_APPS = (
    "modeltranslation",
    # ...
    "iubenda",
    # ...
)
  1. Modify settings.py by adding the app's context processor to TEMPLATES:
TEMPLATES = [
    {
        # ...
        'OPTIONS': {
            'context_processors': [
                # ...
                'iubenda.context_processors.iubenda',
                # ...
            ],
        },
    },
]
  1. Be sure the Django's Locale middleware is enabled inside settings.py:
MIDDLEWARE = (
    # ...
    'django.middleware.locale.LocaleMiddleware',
    # ...
)
  1. Be sure the variable LANGUAGE_CODE is available for HTML templates:
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
  1. Modify your project's template to add privacy and cookie policies. For example inside the footer.html add following code:
{% if not debug %}
    {% block iubenda %}{% include "iubenda/include-content.html" %}{% endblock iubenda %}
{% endif %}

Optional

Content Security Policy

If Content Security Policy are implemented in your server and inline scripts are disabled, the variable IUBENDA_CSP_NONCE can be set with nonce tag will be inserted script's nonce.

<script type="text/javascript" {% if cx_iubenda_nonce %}nonce="{{ cx_iubenda_nonce }}"{% endif %}>

Iubenda's Options

To personalize the Iubenda script behaviour, the dict IUBENDA_OPTIONS can be configured inside settings.py

IUBENDA_OPTIONS = {"ccpaAcknowledgeOnDisplay": "true",
                   "ccpaApplies": "true",
                   "consentOnContinuedBrowsing": "false",
                   "enableCcpa": "true",
                   "floatingPreferencesButtonDisplay": "bottom-left",
                   "invalidateConsentWithoutLog": "true",
                   "perPurposeConsent": "true",
                   "whitelabel": "false",
                   "banner": {
                       "acceptButtonDisplay": "true",
                       "backgroundOverlay": "true",
                       "closeButtonRejects": "true",
                       "customizeButtonDisplay": "true",
                       "explicitWithdrawal": "true",
                       "fontSize": "14px",
                       "listPurposes": "true",
                       "position": "float-center",
                       "rejectButtonDisplay": "true"
                   }
                   }

Run Example Project

git clone --depth=50 --branch=django-iubenda https://github.com/DLRSP/example.git DLRSP/example
cd DLRSP/example
python manage.py runserver

Now browser the app @ http://127.0.0.1:8000

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-iubenda-0.1.12.dev0.tar.gz (43.8 kB view hashes)

Uploaded Source

Built Distributions

django_iubenda-0.1.12.dev0-py3.10.egg (25.0 kB view hashes)

Uploaded Source

django_iubenda-0.1.12.dev0-py2.py3-none-any.whl (26.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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