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 = {
    "title": "Cookie settings",
    "header_text": "We are using cookies on this website. A few are essential, others are not.",
    "footer_text": "Please accept our cookies",
    "footer_links": [
        { "title": "Impprint", "href": "/imprint"},
        { "title": "Privacy", "href": "/privacy"},
    ],
    "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.5.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

django_cookiebanner-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file django-cookiebanner-0.1.5.tar.gz.

File metadata

  • Download URL: django-cookiebanner-0.1.5.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.6.9 Linux/4.15.0-91-generic

File hashes

Hashes for django-cookiebanner-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2ef8bfacf5f3d81cd401e71c15a05077e06d4ddf609b71ec094613e1ee1b57e1
MD5 40dde894caa46c7d5c4b324ba1232e35
BLAKE2b-256 4d1bba5078d64b65080907b7b5609c06ce5f6e0e998e09c38a08356536700dc1

See more details on using hashes here.

Provenance

File details

Details for the file django_cookiebanner-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cookiebanner-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dc503a14804bf9660223997618dc33ba942ad54bf1222581a7ddc7355562dae0
MD5 044f64393493824a3ef63298028ac691
BLAKE2b-256 da8666773ee7cb44360cd561212d6b31218752667146d41961bf27ef04103b2e

See more details on using hashes here.

Provenance

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