Задать вопрос

Тел: +7 965 3737 888

491

Просмотров

1

Ответов

SectionedForm

<p>Sometimes we need divide forms in fieldsets, but this make us declare all fields in HTML template manually.</p>
<p>This class is to help you to do this by a easy way.</p>
<p><strong>How to use</strong></p>
<p>First, download this file as name "sectioned_form.py"</p>
<p>Later, turn your form inherited from the class <strong>SectionedForm</strong>, override method "_html_output" and declare fieldsets and fieldset_template attribute, like below:</p>
from sectioned_form import SectionedForm

class MyForm(forms.ModelForm, SectionedForm):
    fieldsets = (
        (None, ('name','age','date')),
        (_('Documents'), ('number','doc_id')),
    )
    fieldset_template = "&lt;h2&gt;%s&lt;/h2&gt;"

    def _html_output(self, *args, **kwargs):
        return SectionedForm._html_output(self, *args, **kwargs)

Вопрос полезен? Да0/Нет0
file_4219.py(3.0Кб)
None

Ответы (1):

Ответmarinho:08.08.2008
Ответ полезен? Да0/Нет0

Variables sections and section_template changed to fieldsets and fieldset_template.