forms.py¶
Standard baseclass form definitions & some widget definitions
Class definitions:
-
class
core.forms.QuerysetWrapper(objects)[source]¶ Bases:
objectQueryset wrapper for caching the choices coupled to a ManyToManyField. The querysetwrapper provides functions which otherwise should be called on the queryset directly.
Dramatically reduces the amount of queries needed when rendering form fieldsets via a fieldset template.
-
class
core.forms.BaseClassForm[source]¶ Bases:
objectBase class form which holds the functions shared among all forms. Automatically adds placeholders
-
add_placeholders_to_fields()[source]¶ Automatically add the ‘placeholder’ attribute to appropiate HTML input elements
-
fieldsets()[source]¶ Instead of using fields on forms, fieldsets are used. This allows ordening the fields in sets and hiding/showing different sets based on selected values
-
queryset_speed_up()[source]¶ Dramatically decreases the amount of queries necessary in template rendering of ManyToManyFields by replacing the queryset with a
QuerysetWrapperinstance.If not replaced, every time the (BoundField) ‘field’ variable is used in the template the choices are retrieved from the database, resulting in some cases in 40+ queries.
Execute this function in the __init__ of forms that have one or more instances of
ModelMultipleChoiceField
-
-
class
core.forms.BaseForm(*args, **kwargs)[source]¶ Bases:
django.forms.forms.Form,core.forms.BaseClassFormBaseclass form which is based on forms.Form
-
class
core.forms.BaseModelForm(*args, **kwargs)[source]¶ Bases:
django.forms.models.ModelForm,core.forms.BaseClassFormBaseclass form which is based on forms.ModelForm
-
class
core.forms.DisplayWidget(attrs=None)[source]¶ Bases:
django.forms.widgets.WidgetWidget for displaying values
-
class
core.forms.ImageField(*args, **kwargs)[source]¶ Bases:
django.forms.fields.ImageFieldOverride ImageField to allow setting a maximum upload size and checking mime_type with help of the ‘magic’ package.
-
class
core.forms.MultipleChoiceField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)[source]¶ Bases:
django.forms.fields.MultipleChoiceFieldDjango formfield for multiple selections
-
class
core.forms.ModelMultipleChoiceField(queryset, required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)[source]¶ Bases:
django.forms.models.ModelMultipleChoiceFieldDjango formfield for multiple selections
-
class
core.forms.ChoiceOtherWidget(choices, other_field, maxlength=128, attrs=None)[source]¶ Bases:
django.forms.widgets.MultiWidgetDjango widget for choice other fields
Displays a select box with the option for ‘other’ allowing to specify a value via a textinput
-
class
core.forms.ChoiceOtherField(choices=[], *args, **kwargs)[source]¶ Bases:
django.forms.fields.MultiValueFieldDjango formfield for choice other fields
-
fix_value_from_post(post_data, field_name)[source]¶ Used for fixing post data so it can be temporarily stored in the database and later used as form initial data
-
-
class
core.forms.FormRadioSelect(attrs=None, choices=())[source]¶ Bases:
django.forms.widgets.RadioSelectDjango formfield which overrides the radio select field
-
class
core.forms.SelectDateWidgetCustom(attrs=None, years=None, format=None, required=True)[source]¶ Bases:
core.widgets.SelectDateWidgetBase class for SelectDateWidget, SelectDateTimeWidget and SelectTimeWidget.
-
class
core.forms.DateWidget(attrs=None, years=None, format=None, required=True)[source]¶ Bases:
core.forms.SelectDateWidgetCustomDjango Widget for selecting dates
-
class
core.forms.FormDateField(*args, **kwargs)[source]¶ Bases:
django.forms.fields.DateFieldDjango Formfield for dates
-
widget¶ alias of
DateWidget
-
fix_value_from_post(post_data, field_name)[source]¶ Used for fixing post data so it can be temporarily stored in the database and later used as form initial data
-