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 choices that Customize and the Cookie settings link open:
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 Wagtaildjango.template.context_processors.requestin your template settings. Wagtail's project template has it. Without it, the banner doesn't load.
Installation
-
Install the package:
pip install wagtail-cookie-consent
-
Add it to
INSTALLED_APPS, withwagtail.contrib.settings:INSTALLED_APPS = [ # ... "wagtail.contrib.settings", "wagtail_cookie_consent", # ... ]
-
Create its table:
python manage.py migrate
-
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>
-
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:
- Tutorial: Getting started.
- How-to guides: add the Cookie settings link, act on the visitor's choice, build your own consent page, change the colors, add the banner to other templates, see the banner in browser tests, and troubleshoot.
- Reference: settings, template tags, and the script API.
- Explanation: how the banner works, and privacy.
Links
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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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.
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.