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:

from django.utils.translation import ugettext_lazy as _

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": _("Imprint"),
            "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.2.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

django_cookiebanner-0.2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-cookiebanner-0.2.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.2 Linux/5.4.0-42-generic

File hashes

Hashes for django-cookiebanner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 632d6d058532209d0be907c216126579674113feeb147fcefd11d231f265fd58
MD5 9b1c73224f8dfec17209561b05514014
BLAKE2b-256 53cedd2989b7c405f834f7fe61acba59fea54509ac96e24ce85a46bfd2a7af1f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for django_cookiebanner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb0c9ef21c9203aa6bd7080a927e96dcdcc5f94c0fe1124e5fa744d5f62c6c93
MD5 1082af15c0da463b3a956be57527ee8f
BLAKE2b-256 cbf5e5801fc128855a35dfd7fe1f21c1a411f27683a1789f13f9f5c27f6ea9d5

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