djangodocs.org

238 sections in Django 4.2 Search all versions →

Templates

Release notes Django 1.7 release notes What’s new in Django 1.7Minor features

The Context.push() method now returns a context manager which automatically calls pop() upon exiting the with statement. Additionally, push() now accepts parameters that are passed to the dict constructor used to build the new context level.

Bugfixes

Release notes Django 1.8.1 release notes

Added support for serializing timedelta objects in migrations (#24566). Restored proper parsing of the testserver command’s positional arguments (fixture names) (#24571). Prevented TypeError in translation functions check_for_language() and get_language_bidi() when translations are deactivated (#24569).

Reference GIS QuerySet API Reference Spatial Lookupsrelate

On these spatial backends the intersection pattern is a string comprising nine characters, which define intersections between the interior, boundary, and exterior of the geometry field and the lookup geometry.

Oracle

Reference GIS QuerySet API Reference Spatial Lookupsrelate

Here the relation pattern is comprised of at least one of the nine relation strings: TOUCH, OVERLAPBDYDISJOINT, OVERLAPBDYINTERSECT, EQUAL, INSIDE, COVEREDBY, CONTAINS, COVERS, ON, and ANYINTERACT. Multiple strings may be combined with the logical Boolean operator OR, for example, 'inside+touch'.

Models

Release notes Django 1.8 release notes What’s new in Django 1.8Minor features

Django now logs at most 9000 queries in connections.queries, in order to prevent excessive memory usage in long-running processes in debug mode.

Select

Reference Widgets Built-in widgetsSelector and checkbox widgets

classSelect : - template_name: 'django/forms/widgets/select.html' - option_template_name: 'django/forms/widgets/select_option.html' - Renders as: <select><option ...>...</select>

select_on_save

Reference Model Meta options Available Meta options

Options.select_on_save : Determines if Django will use the pre-1.6 django.db.models.Model.save() algorithm. The old algorithm uses SELECT to determine if there is an existing row to be updated. The new algorithm tries an UPDATE directly.

select_for_update()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

Evaluating a queryset with select_for_update() in autocommit mode on backends which support SELECT ... FOR UPDATE is a TransactionManagementError error because the rows are not locked in that case.

Reference Databases MySQL notes

MySQL and MariaDB do not support some options to the SELECT ... FOR UPDATE statement. If select_for_update() is used with an unsupported option, then a NotSupportedError is raised.

ChoiceField

Reference Form fields Built-in Field classes

classChoiceField(**kwargs) : - Default widget: Select - Empty value: '' (an empty string) - Normalizes to: A string. - Validates that the given value exists in the list of choices. - Error message keys: required, invalid_choice

FilePathField

Reference Form fields Built-in Field classes

classFilePathField(**kwargs) : - Default widget: Select - Empty value: '' (an empty string) - Normalizes to: A string. - Validates that the selected choice exists in the list of choices. - Error message keys: required, invalid_choice

ModelChoiceField

Reference Form fields Fields which handle relationships

classModelChoiceField(**kwargs) : - Default widget: Select - Empty value: None - Normalizes to: A model instance. - Validates that the given id exists in the queryset. - Error message keys: required, invalid_choice

NullBooleanSelect

Reference Widgets Built-in widgetsSelector and checkbox widgets

classNullBooleanSelect : - template_name: 'django/forms/widgets/select.html' - option_template_name: 'django/forms/widgets/select_option.html'

SelectMultiple

Reference Widgets Built-in widgetsSelector and checkbox widgets

classSelectMultiple : - template_name: 'django/forms/widgets/select.html' - option_template_name: 'django/forms/widgets/select_option.html'

SelectDateWidget

Reference Widgets Built-in widgetsComposite widgets

classSelectDateWidget : - template_name: 'django/forms/widgets/select_date.html'

CheckboxSelectMultiple

Reference Widgets Built-in widgetsSelector and checkbox widgets

classCheckboxSelectMultiple : - template_name: 'django/forms/widgets/checkbox_select.html' - option_template_name: 'django/forms/widgets/checkbox_option.html' Like RadioSelect, you can loop over the individual checkboxes for the widget’s choices.

extra()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

extra(select=None,where=None,params=None,tables=None,order_by=None,select_params=None) Sometimes, the Django query syntax by itself can’t easily express a complex WHERE clause. For these edge cases, Django provides the extra() QuerySet modifier — a hook for injecting specific clauses into the SQL generated by a QuerySet.