No project description provided
Project description
Django-Cookiebanner
Installation
pip install django-cookiebanner
Usage
-
Add
cookiebanner
to yourINSTALLED_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 'vanilla' %}
...
{% cookie_accepted 'analytics' as cookie_analytics %}
{% if cookie_analytics %}
<script>... javascript for matomo ...</script>
{% endif %}
</body>
Custom Template
You can create a custom template and use that instead of the default one.
- Create a folder
cookiebanner/
and a file in one of yourtemplates/
-folders, e.g.:templates/cookiebanner/mytemplate.html
- Use
{% cookiebanner_modal 'mytemplate' %}
Project details
Release history Release notifications | RSS feed
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.5.tar.gz
(19.8 kB
view hashes)
Built Distribution
Close
Hashes for django-cookiebanner-0.2.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d054730e609fcf52e33b90f6b742f6237d4f49343399926cd38508330e921b7 |
|
MD5 | d2212fd0c29d8442af9a30e9d62eb16e |
|
BLAKE2b-256 | 99ca185c773a70f510da4e6f5bbc27a056527c6ace6546b587d3a61c7396dfab |
Close
Hashes for django_cookiebanner-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 058de9e54c7997480a5470bad9ff763c9339e8cce0695f6705133f2cde19cef7 |
|
MD5 | 6a60c204670368458d9199ee69ea8481 |
|
BLAKE2b-256 | 7c2d55c6880bdfa294e7c4f28045ebe514c2ad0aee11f9c967a238eada8ece7d |