skip to navigation
skip to content

django-form-renderers 0.3.2

Sometimes form.as_p doesn't cut it. This app adds more render methods to all forms. It also adds BEM style CSS classes to all form widgets and inputs.

Django Form Renderers

Sometimes form.as_p doesn’t cut it. This app adds more render methods to all forms.


  1. Install or add django-form-renderers to your Python path.
  2. Add form_renderers to your INSTALLED_APPS setting.

What it does

  1. Every form receives a div-based render method called as_div.
  2. If a field is required then an attribute required="required" is rendered for every widget. This is a safe blanket assumption.
  3. Optional - every field and input gets extra BEM CSS classes.

Defining your own renderers

Create either or form_renderers/ in your app. Each renderer must be a function:

def as_some_renderer(form):
    return form._html_output(

def as_another_renderer(form):
    return form._html_output(

You can override the default as_div by creating a renderer called as_div in your app. The same rules that apply for Django template overriding apply to renderer overriding.

Replace as_p and / or as_table globally

Most third party apps use as_p or as_table for rendering. Replace it globally by setting:

FORM_RENDERERS = {"replace-as-p": True, "replace-as-table": True}


BEM is a CSS naming convention that advocates explicit naming over inheritance. Django forms, fields and widgets are not BEM aware. To enabled BEM classes from settings do:

FORM_RENDERERS = {"enable-bem-classes": True}


Praekelt Consulting

  • Hedley Roos



  1. Django 1.10 tests pass. Handle Django 1.11 widget refactor gracefully.


  1. Add a setting allowing as_p and as_table to be overridden globally.


  1. Add a span tag hook for choice inputs. This allows CSS selectors to target the text inside the label tag.


  1. Optional BEM classes.
  2. Standardize as_div.


  1. Allow apps to specify custom renderers.


  1. First release.
File Type Py Version Uploaded on Size
django-form-renderers-0.3.2.tar.gz (md5) Source 2017-05-03 8KB
django_form_renderers-0.3.2-py2.7.egg (md5) Python Egg 2.7 2017-05-03 15KB