django-iubenda 
GitHub

Test

Compliance for websites and apps
Click here and get 10% discount on first year at Iubenda
Check Demo Project
- Check the demo repo on GitHub
Requirements
- Python 3.8 or newer.
- Django 3.2 or newer (see package metadata for supported releases).
- django-requests-api (
requests_api) — shared HTTP client; typical import:from requests_api import RequestsApi, normalize_api_language, copy_get_params_with_overrides, requests_api_for_base.
Setup
- Install from pip:
pip install django-iubenda
- Modify
settings.pyby adding the apps toINSTALLED_APPS(same pattern as other DLRSP integrations that use django-requests-api):INSTALLED_APPS = ( "modeltranslation", # ... "requests_api", "iubenda", # ... )
- Modify
settings.pyby adding the app's context processor toTEMPLATES:TEMPLATES = [ { # ... "OPTIONS": { "context_processors": [ # ... "iubenda.context_processors.iubenda", # ... ], }, }, ]
- Be sure the Django's Locale middleware is enabled inside
settings.py:MIDDLEWARE = ( # ... "django.middleware.locale.LocaleMiddleware", # ... )
- Optionally, enable Django’s CurrentSiteMiddleware in
settings.py:MIDDLEWARE = ( # ... "django.contrib.sites.middleware.CurrentSiteMiddleware", # ... )
- In
urls.py, include the app’s URLconf:urlpatterns += [ path("", include("iubenda.urls")), ]
- Register the app’s sitemaps (for example in
urls.pyor wherever you definesitemaps):from iubenda.sitemaps import PrivacySitemap, CookieSitemap sitemaps = { # ... "privacy": PrivacySitemap, "cookie": CookieSitemap, # ... }
- Be sure the variable
LANGUAGE_CODEis available for HTML templates:{% load i18n %} {% get_current_language as LANGUAGE_CODE %} - In your base layout or footer template, include the Iubenda fragment—for example in
footer.html:{% if not debug %} {% block iubenda %}{% include "iubenda/include-content.html" %}{% endblock iubenda %} {% endif %}
Configuration (APP_CONFIG and IUBENDA_*)
Options are resolved in iubenda.conf, consistent with other DLRSP apps (for example copyai):
- Top-level
IUBENDA_*(empty strings are skipped for string settings so the next source can apply). APP_CONFIG["iubenda"]— keys such asAPI_BASE_URL,API_ALLOWED_LANGS,API_FALLBACK_LANG,API_TIMEOUT,USE_COMPRESS,OPTIONS,GTM,CSP_NONCE,AUTOBLOCKING.- Defaults in
iubenda.defaults.
APP_CONFIG = {
"iubenda": {
"API_TIMEOUT": 45,
"GTM": True,
"OPTIONS": {"perPurposeConsent": "true"},
},
}
Full reference: docs/tutorial/configuration.md (MkDocs: Tutorials → Configuration (APP_CONFIG)). Optional APP_CONFIG["requests_api"] for django-requests-api is documented in that package; django-iubenda policy API timeouts stay under iubenda.conf (IUBENDA_API_TIMEOUT / API_TIMEOUT).
Optional
Autoblocking
If Iubenda autoblocking's configurations are implemented in your account,
set IUBENDA_AUTOBLOCKING or APP_CONFIG["iubenda"]["AUTOBLOCKING"] to enable the script.
<script src="https://cs.iubenda.com/autoblocking/{{ cx_iubenda.iub_site_id }}.js"></script>
Privacy and cookie API requests
The privacy and cookie views call Iubenda’s HTTP API with a lang query parameter aligned to request.LANGUAGE_CODE and to the languages your policies support. Values are read via iubenda.conf (IUBENDA_API_* and/or APP_CONFIG["iubenda"] keys API_BASE_URL, API_ALLOWED_LANGS, API_FALLBACK_LANG, API_TIMEOUT).
IUBENDA_API_BASE_URL/API_BASE_URL— base URL for API calls (default:https://www.iubenda.com).IUBENDA_API_ALLOWED_LANGS/API_ALLOWED_LANGS— allowedlangvalues (default:it,en).IUBENDA_API_FALLBACK_LANG/API_FALLBACK_LANG— used when the active language is not allowed (default:en).IUBENDA_API_TIMEOUT/API_TIMEOUT— seconds for API HTTP calls (default:30).
Use iubenda.api for Iubenda-specific helpers (they use iubenda.conf), or from requests_api import … for the shared client. Tutorials: docs/tutorial/http-api.md, docs/tutorial/configuration.md.
Content Security Policy
If you use a Content Security Policy and block inline scripts unless they carry a nonce, set IUBENDA_CSP_NONCE or APP_CONFIG["iubenda"]["CSP_NONCE"] so django-iubenda can render script tags with a nonce attribute. Your server or middleware must issue a fresh nonce per response and pass it into templates like your other inline scripts.
<script {% if cx_iubenda_nonce %}nonce="{{ cx_iubenda_nonce }}"{% endif %}>
Allow Iubenda hosts in the relevant CSP directives (script-src, connect-src, img-src, style-src, frame-src, etc.). Details depend on your stack; use Iubenda’s guide and your browser console. If you avoid 'unsafe-inline', you may need hash sources for specific snippets.
Iubenda: Content Security Policy and iubenda scripts
Iubenda options
Set IUBENDA_OPTIONS or APP_CONFIG["iubenda"]["OPTIONS"] in settings.py:
IUBENDA_OPTIONS = {
"countryDetection": "true",
"askConsentAtCookiePolicyUpdate": "true",
"enableFadp": "true",
"enableLgpd": "true",
"lgpdAppliesGlobally": "true",
"enableUspr": "true",
"enableCcpa": "true",
"ccpaAcknowledgeOnDisplay": "true",
"ccpaApplies": "true",
"consentOnContinuedBrowsing": "false",
"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",
"showPurposesToggles": "true",
},
}
Integration with Google Tag Manager
If Google Tag Manager is implemented in your application and all needed settings were configured inside the container,
set IUBENDA_GTM = True or APP_CONFIG["iubenda"]["GTM"] = True so the Iubenda callback is inserted into the script.
For needed configuration inside Google Tag Manager container, please refer to these notes:
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
Metadata
Release files for django-iubenda 1.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_iubenda-1.7.4.tar.gz | 89.3 kB | Without provenance | Details for django_iubenda-1.7.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_iubenda-1.7.4-py3-none-any.whl | Python 3 | none | any | Details for django_iubenda-1.7.4-py3-none-any.whl |
Total release size: 123.5 kB
Release files / django_iubenda-1.7.4.tar.gz
| Download URL | django_iubenda-1.7.4.tar.gz |
|---|---|
| Size | 89.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4aede06f3880cc24ebd3cb14f7c48b732872b2ac78d779847def0e300aa5f74
|
|
BLAKE2b-256 checksum How to use checksums |
6dc4bef87679e5334eee3e4af581a67203ef44338bfb9f00369744d44dbf9853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / django_iubenda-1.7.4-py3-none-any.whl
| Download URL | django_iubenda-1.7.4-py3-none-any.whl |
|---|---|
| Size | 34.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a55b1cd5cbd859a0a9abb9a7373ad75caa53877fcc1874fe31004f73f120042
|
|
BLAKE2b-256 checksum How to use checksums |
a8e68d97eb217555dfbc80345b85d5550ff591053d31042bd5ee146707fa232c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for django-iubenda 1.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.