Skip to main content

django-cookie-monster

CircleCI Maintainability Coverage Status

This package gives you two versions of a cookie banner. The simple one is basically just a hint to inform users that you are using cookies. The group version let's your users decide which cookies he needs.

Quickstart

Install django-cookie-monster::

pip install django-cookie-monster

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'cookie_monster',
    ...
)

Add a type and data property to all script tags that store any cookies.

<!-- before -->
<script>// This is my script</script>

<!-- after -->
<script type="text/plain" data-cookieconsent="the_ID_of_my_group">// This is my script</script>

Settings

Overwrite strings in your settings file. You will find a complete reference below.

COOKIE_MONSTER = {
    'banner': {
        'title': 'My Cookie Banner Title',
    }
}

To switch from standard to group mode you need to specify a list of setting groups.

COOKIE_MONSTER = {
    'cookie_groups': {
        'rows': [
            'Name',
            'Provider',
            'Purpose',
        ],
        'groups': [
            {
                'title': 'Necessary',
                'required': True,
                'cookies': [
                    {
                        'id': 'application',
                        'rows': [
                            'Language',
                            'example.com',
                            'site language',
                        ],
                    },
                ],
            },
            {
                'title': 'Marketing',
                'required': False,
                'cookies': [
                    {
                        'id': 'GTM',
                        'rows': [
                            'Google Tag Manager',
                            'Google.com',
                            'tracking cookie',
                        ],
                    },
                ],
            },
        ],
    },
}

This is an example of a fully customised version of a cookie banner:

COOKIE_MONSTER = {
    'banner': {
        'title': 'My Cookie Banner Title',
        'text': 'This is my custom text with a dynamic <a href="https://example.com/">link</a> to another page.',
        'policy_link': 'contents.utils.my_callable_that_returns_a_dynamic_link_to_the_privacy_page',
        'buttons': {
            'confirm': {'label': 'Accept all cookies'},
            'toggle': {'label': 'Toggle settings'},
            'accept_all_cookies': {'label': 'Accept all Cookies'},
            'accept_all_group_cookies': {'label': 'Accept {groupTitle} Cookies'}
        },
    },
    'accordion_title': '{groupTitle} ({amount})',
    'cookie': {
        'samesite': 'Lax'
    },
    'custom_theme': True,
    'cookie_groups': {
        'rows': [
            'Name',
            'Provider',
            'Purpose',
        ],
        'groups': [
            {
                'title': 'Necessary',
                'required': True,
                'cookies': [
                    {
                        'id': 'application',
                        'rows': [
                            'Language',
                            'example.com',
                            'site language',
                        ],
                    },
                ],
            },
            {
                'title': 'Marketing',
                'required': False,
                'cookies': [
                    {
                        'id': 'GTM',
                        'rows': [
                            'Google Tag Manager',
                            'Google.com',
                            'tracking cookie',
                        ],
                    },
                ],
            },
        ],
    },
}

Contribute

Installation

To install the frontend you will need to run:

npm i

Building frontend

The frontend can be built via:

npm run build

Unit test

You can unit test the frontend code with:

npm test

History

0.1.8.2 (2023-05-15) ++++++++++++++++++

  • Simplify imports

0.1.8.1 (2023-04-20) ++++++++++++++++++

  • Include *.map files in source distribution

0.1.8 (2023-02-02) ++++++++++++++++++

  • Add Django 4 compatibility

0.1.7 (2022-10-11) ++++++++++++++++++

  • Add samesite configuration option

0.1.6 (2022-01-31) ++++++++++++++++++

  • Simplify banner text to prevent fails

DEPRECATION WARNING:

  • The setting variable policy_link was removed due to errors. Please handle any text/link combinations yourself.

0.1.5 (2021-02-15) ++++++++++++++++++

  • Add plain html support for the groups labels

0.1.4 (2020-05-13) ++++++++++++++++++

  • Improve backward compatibility of browsers

0.1.3 (2020-05-13) ++++++++++++++++++

  • Fix translation issue in banner text

0.1.2 (2020-04-09) ++++++++++++++++++

  • Bugfix

0.1.1 (2020-04-08) ++++++++++++++++++

  • Bugfix

0.1.0 (2019-10-16) ++++++++++++++++++

  • First release on PyPI.

Metadata

Release files for django-cookie-monster 0.1.8.2

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

Source distribution (sdist)

Source distribution for django-cookie-monster 0.1.8.2
File Size Uploaded Provenance
django-cookie-monster-0.1.8.2.tar.gz 200.7 kB Without provenance Details

Security for django-cookie-monster 0.1.8.2

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.

No provenance found

None of the files in this release were 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.

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