Skip to main content

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

Project description

Django Form Renderers

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

Travis

Installation

  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.

Defining your own renderers

Create either form_renderers.py or form_renderers/__init__.py 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.

Authors

Praekelt Consulting

  • Hedley Roos

Changelog

0.1.1

  1. Allow apps to specify custom renderers.

0.1

  1. First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-form-renderers-0.1.1.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

django_form_renderers-0.1.1-py2.7.egg (12.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page