djangodocs.org

1305 sections across all versions Narrow to Django 6.0 (current) →

Widget attributes

Reference GeoDjango Forms API Form widgets

BaseGeometryWidget.base_layer : > New in Django 6.0. BaseGeometryWidget.geom_type : The OpenGIS geometry type, generally set by the form field. BaseGeometryWidget.map_srid : SRID code used by the map (default is 4326).

4.2 5.0 5.1 5.2 6.0

Widget classes

Reference GeoDjango Forms API Form widgets

OpenLayersWidget classOpenLayersWidget[source] : This is the default widget used by all GeoDjango form fields. Attributes are: OSMWidget classOSMWidget[source] : This widget specialized OpenLayersWidget and uses an OpenStreetMap base layer to display geographic objects on. Attributes are:

4.2 5.0 5.1 5.2 6.0

Methods of BoundField

Reference The Forms API More granular output

BoundField.legend_tag(contents=None,attrs=None,label_suffix=None)[source] : Calls label_tag() with tag='legend' to render the label with <legend> tags. This is useful when rendering radio and multiple checkbox widgets where <legend> may be more appropriate than a <label>.

4.2 5.0 5.1 5.2 6.0

exclude

Reference Model forms Model form Meta API

ModelFormOptions.exclude : A tuple or list of model field names to be excluded from the form.

5.2 6.0 dev

field_classes

Reference Model forms Model form Meta API

ModelFormOptions.field_classes : A dictionary that maps a model field name to a Field class, which overrides the form_class used in the model field’s Field.formfield() method.

5.2 6.0

fields

Reference Model forms Model form Meta API

ModelFormOptions.fields : A tuple or list of model field names to be included in the form. The value '__all__' can be used to specify that all fields should be included.

5.2 6.0 dev

localized_fields

Reference Model forms Model form Meta API

ModelFormOptions.localized_fields : A tuple or list of model field names to be localized. The value '__all__' can be used to specify that all fields should be localized.

5.2 6.0

modelform_factory

Reference Model forms Model form factory functions

modelform_factory(model,form=ModelForm,fields=None,exclude=None,formfield_callback=None,widgets=None,localized_fields=None,labels=None,help_texts=None,error_messages=None,field_classes=None)[source] : Returns a ModelForm class for the given model. You can optionally pass a form argument to use as a starting point for constructing the ModelForm.

5.2 6.0

Specifying widgets

Reference Widgets

Whenever you specify a field on a form, Django will use a default widget that is appropriate to the type of data that is to be displayed.

4.2 5.0 5.1 5.2 6.0

Topic guide Formsets

Sometimes your form class takes custom parameters, like MyArticleForm. You can pass this parameter when instantiating the formset: The form_kwargs may also depend on the specific form instance. The formset base class provides a get_form_kwargs method.

4.2 5.0 5.1 5.2 6.0

Field data

Topic guide Working with forms More about Django Form classesMore on fields

Whatever the data submitted with a form, once it has been successfully validated by calling is_valid() (and is_valid() has returned True), the validated form data will be in the form.cleaned_data dictionary.

4.2 5.0 5.1 5.2 6.0

BooleanField

Reference Model field reference Field types

classBooleanField(**options)[source] A true/false field. The default form widget for this field is CheckboxInput, or NullBooleanSelect if null=True. The default value of BooleanField is None when Field.default isn’t defined.

4.2 5.0 5.1 5.2 6.0

max_geom_collections

Reference GeoDjango Model API

GeometryField.max_geom_collections This option is forwarded to the form field generated for this model field, bounding the geometry collection nesting depth in submitted WKB/WKT inputs before raising ValueError.

dev

help_text

Reference Model field reference

Field.help_text Extra “help” text to be displayed with the form widget. It’s useful for documentation even if your field isn’t used on a form. Note that this value is not HTML-escaped in automatically-generated forms.

dev

HTML forms

Topic guide Working with forms

In HTML, a form is a collection of elements inside <form>...</form> that allow a visitor to do things like enter text, select options, manipulate objects or controls, and so on, and then send that information back to the server.

dev