skip to navigation
skip to content

django-chang 0.1.0

Simple Django utility library including a Jinja2 connection

# django-chang

Chang is a utility library that I use when developing Django applications. It
comes with Jinja2 for Django (which is highly inspired by [django-jinja][])
and a few other utilities.

### chang.jinja2

The Jinja2 connection provided by *chang* provides a `{% csrf_token %}`
that which can be used in the Jinja2 templates. The `CHANG_JINJA2_VERIFY`
setting is used to determine whether a template should be loaded via
the Jinja2 Environment. It must be a callable object that accepts the
template name as a parameter.

`CHANG_JINJA2_ALWAYS` can be set to True to always load templates as
Jinja2 templates.

Make sure you add `chang.jinja2.FileSystemLoader` and/or
`chang.jinja2.AppDirectoriesLoader` before the Django default template

### chang.local

Provides a Django Middleware that makes the Django request object
available as a LocalProxy which can be accessed via `chang.local.request`
or `chang.request`. Using this removes the requirement to pass the
Django request to each function that requires it.

# ...

from chang.local import request

### chang.utils

The `TemplateRenderer` can be used as a decorator for functions that build
a default context for rendering templates. You can put it in your ``
like this:

from django.utils import timezone
from chang.utils import TemplateRenderer

def render(context):

def home(request):
render(request, 'my_app/home.html')

## License and Copyright

The `chang.jinja2` module is highly inspired by [django-jinja][].

* __Author__: Niklas Rosenstein
* __License__: MIT

File Type Py Version Uploaded on Size
django-chang-0.1.0.tar.gz (md5) Source 2014-04-19 6KB