How to Comply With EU Cookie Law in Django Projects

Blog Post Image

If you're working on a web project that will be accessed from the European Union (EU), you should know there are some very strict cookie restrictions. Basically, you must inform visitors that cookies can, and will, be stored. 

If you're working with Django, we've got you covered. Here's a simple 6-step guide to following the requirements using django-cookie-law.

1) Install django-cookie-law:
$ pip install django-cookie-law

2) Add 'cookielaw' to INSTALLED_APPS:






3) Run collectstatic to gather the media files

python manage.py collectstatic

4) Add the CSS:
<link href="{% static "cookielaw/css/cookielaw.css"%}" rel="stylesheet" />

5) Add the Javascript:
<script src="{% static "cookielaw/js/cookielaw.js"%}" type="text/javascript"></script>

6) Inside the <body>, add the tag that will include the banner:
{% cookielaw_banner %}

And that's it! You should now see the banner on top with an explanation and an accept button. 

Show us your results! Leave a comment with a link to your website and we'll check if the banner's working OK.

Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.