forms.IntegerField.max_value

max_value

forms.ModelChoiceField.empty_label

empty_label By default the <select> widget used by ModelChoiceField will have an empty choice at the top of the list. You can change the text of this label (which is "---------" by default) with the empty_label attribute, or you can disable the empty label entirely by setting empty_label to None: # A custom empty label field1 = forms.ModelChoiceField(queryset=..., empty_label="(Nothing)") # No empty label field2 = forms.ModelChoiceField(queryset=..., empty_label=None) Note that if a

forms.ModelChoiceField.queryset

queryset A QuerySet of model objects from which the choices for the field will be derived, and which will be used to validate the user’s selection. ModelChoiceField also takes two optional arguments:

forms.ImageField

class ImageField(**kwargs) [source] Default widget: ClearableFileInput Empty value: None Normalizes to: An UploadedFile object that wraps the file content and file name into a single object. Validates that file data has been bound to the form, and that the file is of an image format understood by Pillow. Error message keys: required, invalid, missing, empty, invalid_image Using an ImageField requires that Pillow is installed with support for the image formats you use. If you encounter a

forms.GenericIPAddressField.protocol

protocol Limits valid inputs to the specified protocol. Accepted values are both (default), IPv4 or IPv6. Matching is case insensitive.

forms.HiddenInput

class HiddenInput [source] Hidden input: <input type='hidden' ...> Note that there also is a MultipleHiddenInput widget that encapsulates a set of hidden input elements.

forms.IntegerField

class IntegerField(**kwargs) [source] Default widget: NumberInput when Field.localize is False, else TextInput. Empty value: None Normalizes to: A Python integer or long integer. Validates that the given value is an integer. Leading and trailing whitespace is allowed, as in Python’s int() function. Error message keys: required, invalid, max_value, min_value The max_value and min_value error messages may contain %(limit_value)s, which will be substituted by the appropriate limit. Takes tw

forms.GenericIPAddressField.unpack_ipv4

unpack_ipv4 Unpacks IPv4 mapped addresses like ::ffff:192.0.2.1. If this option is enabled that address would be unpacked to 192.0.2.1. Default is disabled. Can only be used when protocol is set to 'both'.

forms.formsets.BaseFormSet.can_delete

BaseFormSet.can_delete Default: False Lets you create a formset with the ability to select forms for deletion: >>> from django.forms import formset_factory >>> from myapp.forms import ArticleForm >>> ArticleFormSet = formset_factory(ArticleForm, can_delete=True) >>> formset = ArticleFormSet(initial=[ ... {'title': 'Article #1', 'pub_date': datetime.date(2008, 5, 10)}, ... {'title': 'Article #2', 'pub_date': datetime.date(2008, 5, 11)}, ... ]) >&

forms.formsets.BaseFormSet.total_error_count()

BaseFormSet.total_error_count() [source] To check how many errors there are in the formset, we can use the total_error_count method: >>> # Using the previous example >>> formset.errors [{}, {'pub_date': ['This field is required.']}] >>> len(formset.errors) 2 >>> formset.total_error_count() 1 We can also check if form data differs from the initial data (i.e. the form was sent without any data): >>> data = { ... 'form-TOTAL_FORMS': '1', ...