django-formfieldset

django-formfieldset is a Django application that allows you define and render your forms with fieldsets. Just like in admin. To enable fieldset rendering you need to add FieldsetMixin as a parent class to your form and define a fieldsets attribute:

from django import forms
from formfieldset.forms import FieldsetMixin


class MyForm(forms.Form, FieldsetMixin):
    # Fields etc...

    fieldsets = ((u'Fieldset Title',
                  {'fields': ('foo', 'bar', 'baz'),
                   'description': u'This is the description for fieldset.'}),
                 (None,
                  {'fields': ('some_field',),
                   'description': u'This fieldset has no title.'}),
                 (u'Fieldset With No Description',
                  {'fields': ('some_other_field',)}))

Then you can render your form with fieldset enabled methods:

<form method="POST" action=""><table>{{ form.as_fieldset_table }}</table></form>

It is far from complete1, but feel free to download and play with it.


1: Not released yet.

Bookmark and Share

Related posts:

  1. Working with files in Django – Part 1
  2. Working with files in Django – Part 2
  3. Working with files in Django – Part 3
  4. My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor
  5. Drawing Gradients with PyGame

Tags: , , , , , ,

Comments are closed.