Skip to main content

Wagtail cookie consent

A cookie consent banner for Wagtail. Our ultimate goal is everything you need to do to set up the banner, you do through the Wagtail admin.

Claude Code was used with oversight by the maintainer.

Summary of Purpose

“Wagtail cookie consent” adds a cookie consent banner to a Wagtail site, and tells the rest of the page what each visitor chose. Who sees the banner, which categories it asks about and what it says are set in the admin UI.

The banner is vanilla-cookieconsent, which ships inside the package, so nothing loads from a third party.

It doesn't block or load other scripts for you, and it doesn't delete cookies another script has set: your analytics or other code acts on the visitor's choice (see Act on the visitor's choice). It also doesn't decide what your site has to ask about; check the rules that apply to your site.

Progress so far

  • A banner on a visitor's first visit, with Accept all, Necessary only and Customize. Accepting and refusing are equally easy, and the category switches start off.
  • The choice is remembered for 182 days, in a cookie on the visitor's device.
  • A Cookie settings link reopens the choices, so a visitor can change or withdraw them at any time.
  • The choice is announced to the page when it's made, when it changes, and on each later page load.
  • A page of your own can show and change the choice.
  • The banner is kept out of preview views automatically (non-configurable).
  • Settings available under Settings → Cookie consent: see the settings reference.

The banner on a visitor's first visit, here with a site's own colors:

The cookie banner in the corner of a page, with Accept all, Necessary only and Customize buttons and a Privacy notice link

The choices that Customize and the Cookie settings link open:

The Cookie settings dialog, with a switch for each category and Accept all, Necessary only and Save my choices buttons

Requirements

  • Wagtail 7.4, 8.0 or 8.1, with the Python and Django versions each of them supports
  • wagtail.contrib.settings, which comes with Wagtail
  • django.template.context_processors.request in your template settings. Wagtail's project template has it. Without it, the banner doesn't load.

Installation

  1. Install the package:

    pip install wagtail-cookie-consent
    
  2. Add it to INSTALLED_APPS, with wagtail.contrib.settings:

    INSTALLED_APPS = [
        # ...
        "wagtail.contrib.settings",
        "wagtail_cookie_consent",
        # ...
    ]
    
  3. Create its table:

    python manage.py migrate
    
  4. Add the banner to <head> in your base template, and the Cookie settings link where you want it, such as the footer:

    {% load wagtail_cookie_consent %}
    <!doctype html>
    <html>
      <head>
        <meta charset="utf-8">
        {% cookie_consent %}
        ...
      </head>
      <body>
        ...
        <footer>{% cookie_settings_link %}</footer>
      </body>
    </html>
    
  5. In the Wagtail admin, go to Settings → Cookie consent and choose the categories your site uses.

The banner's scripts and stylesheet are among the package's static files. On a deployed site, run collectstatic after you install or upgrade the package, as for any app's static files.

Then follow Getting started to see the banner and hear a visitor's choice.

Documentation

The documentation is in four parts:

License

BSD-3-Clause. See LICENSE.

vanilla-cookieconsent is included under the MIT license. Its license is in the package, next to its files.

Metadata

Release files for wagtail-cookie-consent 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-cookie-consent 0.2.1
File Size Uploaded Provenance Actions
wagtail_cookie_consent-0.2.1.tar.gz 28.0 kB With provenance Details for wagtail_cookie_consent-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-cookie-consent 0.2.1
File Interpreter ABI Platform Actions
wagtail_cookie_consent-0.2.1-py3-none-any.whl Python 3 none any Details for wagtail_cookie_consent-0.2.1-py3-none-any.whl

Total release size: 59.7 kB

Security for wagtail-cookie-consent 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page