Skip to main content

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

  1. Add 'cookie_consent' to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
    ...,
    'cookie_consent',
    ]
    
  2. Include the cookie_consent URLconf in your project urls.py like this:

    path('cookies/', include('cookie_consent.urls')),
    
  3. Add the cookie_consent middleware to your MIDDLEWARE setting like this:

    MIDDLEWARE = [
    ...,
    'cookie_consent.middleware.CookieConsentMiddleware',
    ]
    
  4. Use the 'cookie_consent' template tag in your base template like this:

    {% load cookies_tags %}
    {% cookie_consent %}
    
  5. 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 %}
    

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dc_consent-1.tar.gz (20.5 kB view details)

Uploaded Source

Release history Release notifications | RSS feed

4.1.8

1 file

4.1.6

1 file

4.1.5

1 file

4.1.4

1 file

4.1.3

1 file

4.1.2

1 file

4.1.1

1 file

4.1.0

1 file

4.0.9

1 file

4.0.8

1 file

4.0.7

1 file

4.0.6

1 file

4.0.5

1 file

4.0.4

1 file

4.0.3

1 file

4.0.2

1 file

4.0.1

1 file

4.0.0

1 file

3.9.0

1 file

3.8.0

1 file

3.7.0

1 file

3.6.0

1 file

3.5.0

1 file

3.4.0

1 file

3.3.0

1 file

3.2.0

1 file

3.1.0

1 file

3.0.0

1 file

2.9.0

1 file

2.8.0

1 file

2.7.0

1 file

2.6.0

1 file

2.5.0

1 file

2.4.0

1 file

2.3.0

1 file

2.2.0

1 file

2.1.0

1 file

2.0.0

1 file

1.9.0

1 file

1.8.0

1 file

1.7.0

1 file

1.6.0

1 file

1.5.0

1 file

1.4.0

1 file

1.3.0

1 file

1.2.0

1 file

1.1.0

1 file

This release

1 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page