Django port of Marshall Yount's rack-modernizr (https://github.com/marshally/rack-modernizr/)
modernizrdirectory to your Python path.
Add the following middleware to your project’s
The order of MIDDLEWARE_CLASSES is important: the Modernizr Middleware middleware must come after any other middleware that encodes the response’s content (such as GZipMiddleware).
Note: The modernizr code will only display itself if the mimetype of the response is either
application/xhtml+xmland contains a closing
Note: Be aware of middleware ordering and other middleware that may intercept requests and return responses. Putting the modernizr middleware after the Flatpage middleware, for example, means modernizr will not show up on flatpages.
INSTALLED_APPSsetting so Django can find the template files associated with the modernizr.
Alternatively, add the path to the modernizr templates ('path/to/modernizr/templates' to your TEMPLATE_DIRS setting.)
Django Modernizr has a few settings that can be set in
(all are optional):
MODERNIZR_STORAGE: set to ‘cookie’ or ‘session’
- Cookie settings (parity to django.contrib.sessions cookie settings):
MODERNIZR_COOKIE_NAME: Name of the cookie. Default is ‘modernizr’.
MODERNIZR_COOKIE_AGE: Expire time of the cookie. Default is 2 weeks.
MODERNIZR_COOKIE_DOMAIN: Domain name the cookie is issued on. Default is None.
MODERNIZR_COOKIE_SECURE: Whether or not to serve the cookie securely. Default is False.
MODERNIZR_COOKIE_PATH: Path the cookie is issued on. Default is ‘/’.
- Session settings:
MODERNIZR_SESSION_KEY: Session key to use for storage. Default is ‘modernizr’.
- Modernizr rendering options:
MODERNIZR_SENTINEL_IMAGE_URL: URL of sentinel image which includes Modernizr data. Default is ‘/django-modernizr-endpoint.gif’.
MODERNIZR_INCLUDE_TAG: A closing tag of this type will be located, and the Modernizr template will be rendered and inserted just before it. Default is ‘body’.