Snippet List
A login_required decorator that wraps the login view instead of redirecting to it.
This prevents your site from leaking login information with HTTP status codes as explained [here](https://grepular.com/Abusing_HTTP_Status_Codes_to_Expose_Private_Information).
This is the way Django's admin is protected, the difference being that it checks for is_active and is_staff instead of is_authenticated.
With this decorators, users directly see a login form (no redirect), post it to LOGIN_URL and are redirected to the page they first tried to see.
This module provides a middleware that implements a mechanism to
highlight a link pointing to the current URL.
Every link on the rendered page matching the current URL will be highlighted with a 'current_page' CSS class.
The name of the CSS class can be changed by setting `CURRENT_PAGE_CLASS` in the project settings.
Originally done by Martin Pieuchot and Bruno ReniƩ, thanks @davidbgk and @samueladam for improvements & optimizations.
This is the `local_settings.py` trick extended to Django templates.
Sometimes you need to insert some arbitrary code in the HTML of the production site for external service integration like uservoice, typekit, google analytics... You don't want to put this code into source control because some other sites using the same source code may not need it.
So, add this template tag to your collection and do:
{% try_to_include 'head.html' %}
And leave `head.html` out of source control. Then when you need to include some code on your production site, just add the `head.html` template with the desired code to include.
I usually have one included template in the header for extra `<head>` tags, and one in the footer for extra javascript.
Node that the included template is rendered against the current context. If the template doesn't exist, an empty string is returned.
Also see the [full blog post](http://bruno.im/2009/dec/07/silently-failing-include-tag-in-django/) about this tag.
- templatetag
- include
- silent
A coverage test runner that uses the class-based runner introduced with Django 1.2.
Put it in your python path and add to your `settings.py`:
TEST_RUNNER = 'path_to.CoverageRunner'
COVERAGE_MODULES = [
'blog.views',
'projects.views',
'middleware',
]
Compatible with Django 1.2 and higher. You also need Ned Batchelder's `coverage.py` module (`pip install coverage`).
brutasse has posted 4 snippets.