A Django app to add a cookie consent modal to your site.
Project description
Cookie Consent
A Django app to add a cookie consent modal to your site. This can then be used to check if the user has given consent to use cookies.
To clear the cookie preferences; the user can simple navigate to:
reverse('cookie_consent:revoke')
In templates; it is also possible to check if the user has given consent like so:
request.cookie_consent.allows('analytics') -> bool
Quick start
-
Add 'cookie_consent' to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ..., 'cookie_consent', ]
-
Include the cookie_consent URLconf in your project urls.py like this:
path('cookies/', include('cookie_consent.urls')),
-
Add the cookie_consent middleware to your MIDDLEWARE setting like this:
MIDDLEWARE = [ ..., 'cookie_consent.middleware.CookieConsentMiddleware', ]
-
Use the 'cookie_consent' template tag in your base template like this:
{% load cookies_tags %} {% cookie_consent %}
-
Check if the user has given consent to use cookies in your templates like this:
{% consents_to 'analytics' %} <script> // Will only get rendered if the user has given consent to use analytics cookies. </script> {% endconsents_to %}
-
We require you to use two asset files. These are located in:
static/cookie_consent/cookie-consent.css static/cookie_consent/cookie-consent.js
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
File details
Details for the file dc_consent-4.0.9.tar.gz
.
File metadata
- Download URL: dc_consent-4.0.9.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3cc4c40bccf6ef9a31f576853067fc1cf1c36fcf5018034c5001c65bebcd850 |
|
MD5 | 9d98771539aaeb24008dc33cb43a6b07 |
|
BLAKE2b-256 | 0da7cf109be63406f962166d084b8ba58e526a2fcd9b7309bb4c20fa5c520005 |