Usage

Tapeforms provides a Mixin to add the required functionality to the Django forms which is required for rendering the whole form and its fields using Django templates.

from django import forms
from tapeforms.mixins import TapeformMixin

class ContactForm(TapeformMixin, forms.Form):
    name = forms.CharField()
    email = forms.EmailField()
    text = forms.CharField(widget=forms.Textarea)

Together with some template code you get some beautiful rendered forms.

{% load tapeforms %}

<form method="post" action=".">
    {% csrf_token %}
    {% form form %}
    <button type="submit">Submit</button>
</form>

By default, the form will be rendered using the tapeforms/layouts/default.html. To learn how to override the template which is used, please refer to the Advanced usage section.

If you don’t want to override the template, you might also use the as_tapeform shortcut.

<form method="post" action=".">
    {% csrf_token %}
    {{ form.as_tapeform }}
    <button type="submit">Submit</button>
</form>

Note

For a full overview of the methods you might override to customize the rendering of your forms, go to the API Reference for mixins.