This project shows an example of Django GDPR Cookie Consent app integration into a Django project.
As stated by GDPR cookie law, websites that serve content for people from European Union must get consent from website visitors before storing any cookies that are not strictly necessary for the website to function. Not complying with GDPR laws can result in a fine of up to €20 million or 4% of the company's annual revenue, whichever is greater.
Django GDPR Cookie Consent app allows you to set up a modal dialog for cookie explanations and preferences. When a specific cookie section is accepted, the widget loads or renders HTML snippets related to that section. For example, if a visitor approved Performance cookies, they would get Google Analytics loaded.
Using the Django GDPR Cookie Consent app, you store the following information about the cookies in Django project settings:
- What are the cookie sections (e.g. "Essential", "Functionality", "Performance", "Marketing")? Are they bounded with any conditional HTML snippets?
- What are the cookie providers within each section (e.g., "This website," "Google Analytics," "Facebook," "Youtube," etc.)?
- What are the cookies set by each of those providers?
Descriptions for sections, providers, or cookies are translatable. User preferences are saved in a cookie too. If a particular section is unselected later, cookies related to that section are attempted to get deleted.
This video was made using the Selenium tests that are included in this project's code.
Django GDPR Cookie Consent is used at
$ python3 -m venv venv
$ source venv/bin/activate
Get Django GDPR Cookie Consent from Gumroad.
Put the *.whl
file into private_wheels/
directory.
With the virtual environment activated, install pip requirements:
(venv)$ pip install -r requirements.txt
Upgrade your Chrome to the latest version and then run the management command:
(venv)$ python manage.py download_chromedriver
It will download and extract the latest stable webdriver for your Chrome browser to the drivers
directory.
With the virtual environment activated, run database migrations:
(venv)$ python manage.py migrate
(venv)$ python manage.py collectstatic --noinput
With the virtual environment activated, run the tests:
(venv)$ python manage.py test
With the virtual environment activated, run development server:
(venv)$ python manage.py runserver
Browse the local website under http://127.0.0.1:8000 and inspect the cookies in web development tools.
Compare the functionality with the source code.
Check the docs and try to modify the functionality.
The actual website's compliance with the GDRP Cookie Law depends on the configuration of each use case. The Django GDPR Cookie Consent app provides the mechanism to make that possible, but it's up to you how you configure and integrate it.
For technical questions or bug reports, please contact Aidas Bendoraitis at https://www.djangotricks.com/feedback/.