djangodocs.org

717 sections in Django dev Search all versions →

DateTimeField

Reference Model field reference Field types

Takes the same extra arguments as DateField. The default form widget for this field is a single DateTimeInput. The admin uses two separate TextInput widgets with JavaScript shortcuts. WARNING: Always use DateTimeField with a datetime.datetime > instance.

FloatField

Reference Model field reference Field types

The default form widget for this field is a NumberInput when localize is False or TextInput otherwise. NOTE: The FloatField class is sometimes mixed up with the > DecimalField class.

GenericIPAddressField

Reference Model field reference Field types

classGenericIPAddressField(protocol='both',unpack_ipv4=False,**options)[source] An IPv4 or IPv6 address, in string format (e.g. 192.0.2.30 or 2a02:42fe::4). The default form widget for this field is a TextInput.

TextField

Reference Model field reference Field types

The default form widget for this field is a Textarea. If you specify a max_length attribute, it will be reflected in the Textarea widget of the auto-generated form field. However it is not enforced at the model or database level.

TimeField

Reference Model field reference Field types

classTimeField(auto_now=False,auto_now_add=False,**options)[source] A time, represented in Python by a datetime.time instance. Accepts the same auto-population options as DateField. The default form widget for this field is a TimeInput. The admin adds some JavaScript shortcuts.

Arguments

Reference Model field reference Relationship fieldsManyToManyField

ForeignKey.related_name : The name to use for the relation from the related object back to this one. It’s also the default value for related_query_name (the name to use for the reverse filter name from the target model).

Methods

Reference Request and response objects FileResponse objects

HttpRequest.build_absolute_uri(location=None)[source] : Returns the absolute URI form of location. If no location is provided, the location will be set to request.get_full_path().

STATIC_URL

Reference Settings Static Files

Default: None URL to use when referring to static files located in STATIC_ROOT. Example: "static/" or "https://static.example.com/" If not None, this will be used as the base path for asset definitions (the Media class) and the staticfiles app.

Reference

Standard HttpResponse objects are static structures. They are provided with a block of pre-rendered content at time of construction, and while that content can be modified, it isn’t in a form that makes it easy to perform modifications.

Formsets

Topic guide

classBaseFormSet[source] A formset is a layer of abstraction to work with multiple forms on the same page. It can be best compared to a data grid.

Topic guide Formsets

In the rendered HTML, formsets include a prefix on each field’s name. By default, the prefix is 'form', but it can be customized using the formset’s prefix argument.

Topic guide Formsets

Formsets have the following attributes and methods associated with rendering: BaseFormSet.renderer : Specifies the renderer to use for the formset. Defaults to the renderer specified by the FORM_RENDERER setting.

Topic guide Formsets Using a formset in views and templates

If you manually render fields in the template, you can render can_delete parameter with {{ form.DELETE }}: Similarly, if the formset has the ability to order (can_order=True), it is possible to render it with {{ form.ORDER }}.

Topic guide Formsets Using a formset in views and templates

You are able to use more than one formset in a view if you like. Formsets borrow much of its behavior from forms.