djangodocs.org

663 sections in Django 5.0 Search all versions →

IntegerRangeField

Reference PostgreSQL specific model fields Range Fields

classIntegerRangeField(**options) : Stores a range of integers. Based on an IntegerField. Represented by an int4range in the database and a django.db.backends.postgresql.psycopg_any.NumericRange in Python.

BigIntegerRangeField

Reference PostgreSQL specific model fields Range Fields

classBigIntegerRangeField(**options) : Stores a range of large integers. Based on a BigIntegerField. Represented by an int8range in the database and a django.db.backends.postgresql.psycopg_any.NumericRange in Python.

DateRangeField

Reference PostgreSQL specific model fields Range Fields

classDateRangeField(**options) : Stores a range of dates. Based on a DateField. Represented by a daterange in the database and a django.db.backends.postgresql.psycopg_any.DateRange in Python.

loaddata

Reference django-admin and manage.py Available commands

--format FORMAT Specifies the serialization format (e.g., json or xml) for fixtures read from stdin. --exclude EXCLUDE, -e EXCLUDE Excludes loading the fixtures from the given applications and/or models (in the form of app_label or app_label.ModelName).

Attributes of BoundField

Reference The Forms API More granular output

BoundField.label : The label of the field. This is used in label_tag()/legend_tag(). BoundField.name : The name of this field in the form: BoundField.template_name : > New in Django 5.0. BoundField.use_fieldset : Returns the value of this BoundField widget’s use_fieldset attribute.

Methods of BoundField

Reference The Forms API More granular output

If no widget is specified, then the field’s default widget will be used. BoundField.css_classes(extra_classes=None) : When you use Django’s rendering shortcuts, CSS classes are used to indicate required form fields or fields that contain errors.

Methods of BoundField

Reference The Forms API More granular output

BoundField.legend_tag(contents=None,attrs=None,label_suffix=None) : 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>. BoundField.render(template_name=None,context=None,renderer=None) : > New in Django 5.0.

Reference Widgets

In the following example, the years attribute is set for a SelectDateWidget: See the Built-in widgets for more information about which widgets are available and which arguments they accept.

Styling widget classes

Reference Widgets Customizing widget instances

In a nutshell, you will need to subclass the widget and either define a “Media” inner class or create a “media” property. These methods involve somewhat advanced Python programming and are described in detail in the Form Assets topic guide.

RadioSelect

Reference Widgets Built-in widgetsSelector and checkbox widgets

classRadioSelect : - template_name: 'django/forms/widgets/radio.html' - option_template_name: 'django/forms/widgets/radio_option.html'

Query Expressions

Reference

There are a number of built-in expressions (documented below) that can be used to help you write queries. Expressions can be combined, or in some cases nested, to form more complex computations.

ImageField

Reference Model field reference Field types

As with other fields, you can change the maximum length using the max_length argument. The default form widget for this field is a ClearableFileInput.

Arguments

Reference Model field reference Relationship fieldsManyToManyField

ForeignKey.limit_choices_to : Sets a limit to the available choices for this field when this field is rendered using a ModelForm or the admin (by default, all objects in the queryset are available to choose).

Field API reference

Reference Model field reference

When using [`model forms`](../../topics/forms/modelforms.md#django.forms.ModelForm), the `Field` needs to know which form field it should be represented by: `formfield(form_class=None,choices_form_class=None,**kwargs)` : Returns the default [`django.forms.Field`](../forms/fields.md#django.forms.Field) of this field for [`ModelForm`](../../topics/forms/modelforms.md#django.forms.ModelForm). By default, if both `form_class` and `choices_form_class` are `None`, it uses [`CharField`](../forms/fields.md#django.forms.CharField).

prefetch_related()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

This means that for a large QuerySet a large ‘IN’ clause could be generated, which, depending on the database, might have performance problems of its own when it comes to parsing or executing the SQL query.

Attributes

Reference Request and response objects StreamingHttpResponse objects

HttpRequest.body : The raw HTTP request body as a bytestring. This is useful for processing data in different ways than conventional HTML forms: binary images, XML payload etc. For processing conventional form data, use HttpRequest.POST.

QueryDict objects

Reference Request and response objects

This is necessary because some HTML form elements, notably <select multiple>, pass multiple values for the same key. The QueryDicts at request.POST and request.GET will be immutable when accessed in a normal request/response cycle.

Methods

Reference Request and response objects FileResponse objects

HttpResponse.__init__(content=b'',content_type=None,status=200,reason=None,charset=None,headers=None) : Instantiates an HttpResponse object with the given page content, content type, and headers. HttpResponse.__setitem__(header,value) : Sets the given header name to the given value. Both header and value should be strings.

CSRF_COOKIE_AGE

Reference Settings Core Settings

Without persistent cookies, the form submission would fail in this case.