Using Breve with Django
  1. Installation
  2. Configuration
  3. Writing a Controller
  4. Known Issues
  5. Back to Main Documentation

While no support is strictly required to use Brevé with Django, a preliminary attempt at a Django-specific plugin was introduced in 1.0.21 that mimics the current Django template API to make it more natural to use Brevé with Django.

Installation

You need to add an import to your Django view:

from breve.plugin.django_adapter import loader, render_to_response

Configuration

Using this API will require one setting in your Django configuration file:

BREVE_ROOT = '/path/to/templates'

Unlike Django templates, Brevé will not search the TEMPLATE_PATH (although you can change this by using a custom loader).

Note that this plugin was tested against Django SVN (trunk) on 2007/01/08. Other versions may require modification to the plugin.

Writing a Controller

from django.http import HttpResponse
from breve.plugin.django_adapter import loader

def index ( request ):
    t = loader.get_template ( 'index' )
    return HttpResponse ( t.render ( { 'foo': 'bar' } ) )

The adapter also supports the slightly shorter idiom:

from django.http import HttpResponse
from breve.plugin.django_adapter import render_to_response

def index ( request ):
    return render_to_response ( 'index', { 'foo': 'bar' } )

render_to_string ( ) is supported as well.

Known Issues

I've only done brief testing with Django, although I'm aware of people using Brevé and Django together.

Please report any issues or shortcomings.

edit page
Back to top
Rendered using Brevé 1.2.8Copyright © 2007, Cliff Wells