Skip to main content

A reusable django app for customising form rendering from your template.

Project description

# Django Form Renderer

Provides template filters that allow you to give you power to render forms however you want.

HTML 5 input types are automatically used for field types that are appropriate.

If a field is required, the [required="required"] is automatically added to the element.

More info at:
https://github.com/humphrey/django_formrenderer

## Installation

`pip install django_formrenderer`


## Examples

### Simple HTML5 Example

```HTML+Django/Jinja
{% load renderform %}
<form>
<legend>Your details</legend>
{{ form|renderform:"formrenderer/default.html, name, email, phone" }}

<legend>Extra info</legend>
{{ form|renderform:"formrenderer/default.html, dealer, comments" }}
</form>
```

### Or use HTML 4 (but why would you?)

```HTML+Django/Jinja
{{ form|renderform_html4:"formrenderer/default.html, name, email, phone" }}
```

### Add a class name to a field

Append the field name with the class name. Eg. `my_field.class_name`

```HTML+Django/Jinja
{{ form|renderform:"formrenderer/default.html, name.class_name" }}
```

### Add an attribute

Append the field name with the attribute. Eg. `my_field[key=value]`

```HTML+Django/Jinja
{{ form|renderform:"formrenderer/default.html, comments[rows=3]" }}
{{ form|renderform:"formrenderer/default.html, comments[rows=3,disabled=disabled]" }}
```

### Add class names and attributes

Append the field name with the class name. Eg. `my_field[key=value]`

```HTML+Django/Jinja
{{ form|renderform:"formrenderer/default.html, comments.my_class[rows=3]" }}
```

### Complicated Example

```HTML+Django/Jinja
{% load renderform %}
<form>
{{ form|renderform:"formrenderer/bootstrap_horizontal.html, name.input-block-level, email.input-block-level" }}
<hr/>
{{ form|renderform:"formrenderer/bootstrap_horizontal.html, phone, dealer[class=myClass]" }}
<hr/>
{{ form|renderform:"formrenderer/bootstrap_horizontal.html, comments.input-block-level[rows=3]" }}
</form>
```

Project details


Release history Release notifications | RSS feed

This version

2.0

Download files

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

Source Distribution

django_formrenderer-2.0.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file django_formrenderer-2.0.tar.gz.

File metadata

File hashes

Hashes for django_formrenderer-2.0.tar.gz
Algorithm Hash digest
SHA256 c107c79175e48aff1fa6a5ca012d979cfa12c53aa3afbd5c2a0762a2a32c2a51
MD5 2ee3f2c9f085519065b55b785310ce68
BLAKE2b-256 2d3726d53c365f3b66b4c0869e7dcbd3cc6a0e58c20bce41105f5a081182706a

See more details on using hashes here.

Supported by

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