django-cookie-consent
  • Quickstart
  • Main concepts
  • Usage
  • Javascript integration
  • Settings
  • Example app
  • API Reference
    • Models
    • Views
    • Util
      • are_all_cookies_accepted()
      • dict_to_cookie_str()
      • get_accepted_cookie_groups()
      • get_cookie_value_from_request()
      • get_declined_cookie_groups()
      • get_not_accepted_or_declined_cookie_groups()
      • is_cookie_consent_enabled()
    • Template tags
    • Middleware
  • Contributing
  • Migrating to 1.0
  • Changelog
django-cookie-consent
  • API Reference
  • Util
  • View page source

Util

cookie_consent.util.are_all_cookies_accepted(request: HttpRequest) → bool

Returns if all cookies are accepted.

cookie_consent.util.dict_to_cookie_str(dic: dict[str, str]) → str

Serialize a dictionary of cookie-group metadata to a string.

The result is stored in a cookie itself. Note that the dictionary keys are expected to be cookie group varname fields, which are validated against a slug regex. The values are supposed to be ISO-8601 timestamps.

Invalid key/value pairs are dropped.

cookie_consent.util.get_accepted_cookie_groups(request: HttpRequest) → Collection[CookieGroup]

Returns all cookie groups that are accepted.

cookie_consent.util.get_cookie_value_from_request(request: HttpRequest, varname: str, cookie: str = '') → bool | None

Returns if cookie group or its specific cookie has been accepted.

Returns True or False when cookie is accepted or declined or None if cookie is not set.

cookie_consent.util.get_declined_cookie_groups(request: HttpRequest) → Collection[CookieGroup]

Returns all cookie groups that are declined.

cookie_consent.util.get_not_accepted_or_declined_cookie_groups(request: HttpRequest) → Collection[CookieGroup]

Returns all cookie groups that are neither accepted or declined.

cookie_consent.util.is_cookie_consent_enabled(request: HttpRequest) → bool

Returns if django-cookie-consent is enabled for given request.

Previous Next

© Copyright 2013, Bojan Mihelac.

Built with Sphinx using a theme provided by Read the Docs.