Python django.forms.BaseFormSet() Examples

The following are 3 code examples for showing how to use django.forms.BaseFormSet(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.forms , or try the search function .

Example 1
Project: django-accounting   Author: dulacp   File: introspection_filters.py    License: MIT License 5 votes vote down vote up
def get_form_model_verbose_name(instance):
    if isinstance(instance, ModelForm):
        return instance._meta.model._meta.verbose_name.title()
    if isinstance(instance, BaseFormSet):
        return instance.model._meta.verbose_name_plural.title()
    return '<unknown>' 
Example 2
Project: django-accounting   Author: dulacp   File: form_filters.py    License: MIT License 5 votes vote down vote up
def get_form_model_verbose_name(instance):
    if isinstance(instance, ModelForm):
        return instance._meta.model._meta.verbose_name.title()
    if isinstance(instance, BaseFormSet):
        return instance.model._meta.verbose_name_plural.title()
    return '<unknown>' 
Example 3
Project: website   Author: outreachy   File: export_form.py    License: GNU General Public License v3.0 5 votes vote down vote up
def go(self, obj):
        if isinstance(obj, str):
            self.stdout.write('<h1>{}</h1>'.format(obj))

        elif isinstance(obj, BaseFormSet):
            self.stdout.write('<ol>')
            for idx, form in enumerate(obj, 1):
                self.stdout.write('<li>')
                self.stdout.write(form.as_p())
                self.stdout.write('</li>')
            self.stdout.write('</ol>')

        elif isinstance(obj, BaseForm):
            self.stdout.write(obj.as_p())

        elif callable(obj):
            self.go(obj())

        else:
            try:
                children = iter(obj)
            except TypeError:
                self.stdout.write("<p><code>{!r}</code></p>".format(obj))

            else:
                for child in children:
                    self.go(child)