Skip to main content

No project description provided

Project description

Django-Cookiebanner

Installation

pip install django-cookiebanner

Usage

  • Add cookiebanner to your INSTALLED_APPS

  • in your settings (settings.py) specify the different Cookie Groups:

COOKIEBANNER_GROUPS = [
    {
        "id": "essential",
        "name": "Essential",
        "description": "Essential cookies allow this page to work.",
        "cookies": [
            {"pattern": "cookiebanner", "description": "Meta cookie for the cookies that are set."},
            {"pattern": "csrftoken", "description": "This cookie prevents Cross-Site-Request-Forgery attacks."},
            {"pattern": "sessionid", "description": "This cookie is necessary to allow logging in, for example."},
        ],
    },
    {
        "id": "analytics",
        "name": "Analytics",
        "optional": True,
        "cookies": [
            {"pattern": "_pk_.*", "description": "Matomo cookie for website analysis."},
        ],
    },
]
  • In your base template add the banner and the conditionals:
{% load cookiebanner %}
...
<body>
{% cookiebanner_modal %}
...


{% cookie_accepted 'analytics' as cookie_analytics %}
{% if cookie_analytics %}
<script>... javascript for matomo ...</script>
{% endif %}
</body>

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-cookiebanner-0.1.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

django_cookiebanner-0.1.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded 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