Package: django-cookie-law
django-cookie-lawwill display a dismissable banner, making your users aware of cookies being used.WarningThis app is known to benotcomplaint with the United Kingdom PECR/GDPR.
It is your responsibility to find out whetherdjango-cookie-lawmeets the specific local legal requirements.Contributions and comments are welcome using Github at:http://github.com/TyMaszWeb/django-cookie-lawPlease note that django-cookie-law requires:Django >= 1.8django-classy-tags >= 0.3.0Installationpip installdjango-cookie-lawAdd'cookielaw'toINSTALLED_APPSRuncollectstatic(Django 1.3+) or copy the statics to your media directoryAddcookielaw/js/cookielaw.jsto the markup directly or via your asset
manager such asdjango-pipelineordjango-compressorIf you’re using Django > 1.8, enable'django.core.context_processors.request'in yourTEMPLATES['OPTIONS']setting, eg.:TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.core.context_processors.i18n',
                'django.core.context_processors.media',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.core.context_processors.static',
                'django.core.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]If you’re using an older version of Django (< 1.8) then you’ll want to change theTEMPLATE_CONTEXT_PROCESSORSsetting, eg.:TEMPLATE_CONTEXT_PROCESSORS = (
        'django.contrib.auth.context_processors.auth',
        'django.core.context_processors.debug',
        'django.core.context_processors.i18n',
        'django.core.context_processors.media',
        'django.core.context_processors.request',
        'django.core.context_processors.static',
        'django.core.context_processors.tz',
        'django.contrib.messages.context_processors.messages'
    )NoteN.b. versions below 1.8 are not officially supported.NoteIf you don’t have this setting defined, just add it to your settings module.{% load cookielaw_tags %}and add{% cookielaw_banner %}template
tag where you want to display the cookielaw banner. Best place for this is
your ‘base’ template, so you will have the cookie banner on every page of
your website.ConfigurationIf you want to use our default template, addcookielaw/css/cookielaw.cssto
the markup and you should see the cookie law banner at the top of the page until
you dismiss it with the button in the top-right. This CSS is Twitter Bootstrap
compatible, but chances are, you’ll like to adjust it anyway.To change the markup, just add a template namedcookielaw/banner.htmland
make sure it is loaded before the default template (for example put thedjango.template.loaders.filesystem.Loaderbeforedjango.template.loaders.app_directories.Loaderand add your new template
to any of theTEMPLATE_DIRS).To change the CSS, just write your own rules and don’t include the default
stylesheet.If you want your visitors to be able to reject the cookies, you should setupcookielawcontext processor by adding it toTEMPLATE_CONTEXT_PROCESSORSlike this:TEMPLATE_CONTEXT_PROCESSORS = (
    ...
    'cookielaw.context_processors.cookielaw'
)That will addcookielawcontext variable to the template context. That
variable is a dict with 3 keys:notset,acceptedandrejected, each
withtrueorfalsevalue.Instead of defaultbanner.htmltemplate, userejectable.htmlone which
shows an example of how to reject the cookies (of course, you may change the
template to suit your own needs, just take care that you have<divid="CookielawBanner">container.In your templates, you can choose to display the banner only for new visitors
(case when cookie is not set):{% load cookielaw_tags %}
{% if cookielaw.notset %}{% rejectable_cookielaw_banner %}{% endif %}Of course, you may use{% cookielaw_banner %}as well.Once the visitors accepts or rejects the cookies, you may choose to load or not
load the analytics trackers:{% if cookielaw.accepted %}
    ... the code to load tracker ...
{% endif %}Bugs & ContributionPlease use Github to report bugs, feature requests and submit your code:http://github.com/TyMaszWeb/django-cookie-lawauthor:Piotr Kilczukdate:2013/04/08