djangodocs.org

251 sections in Django 6.0 Search all versions →

distinct()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

distinct(*fields) Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results. By default, a QuerySet will not eliminate duplicate rows.

1.10

Internals Django Deprecation Timeline

ALLOWED_INCLUDE_ROOTS TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_DEBUG TEMPLATE_DIRS TEMPLATE_LOADERS TEMPLATE_STRING_IF_INVALID The backwards compatibility alias django.template.loader.BaseLoader will be removed. Django template objects returned by get_template() and select_template() won’t accept a Context in their render() method anymore.

Topic guide Making queries Retrieving objectsLookups that span relationships

When spanning a ManyToManyField or a reverse ForeignKey (such as from Blog to Entry), filtering on multiple attributes raises the question of whether to require each attribute to coincide in the same related object.

PostgreSQL support

Topic guide Search Use CasesDocument-based search

PostgreSQL has its own full text search implementation built-in. While not as powerful as some other search engines, it has the advantage of being inside your database and so can easily be combined with other relational queries such as categorization.

values()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

values(*fields,**expressions) Returns a QuerySet that returns dictionaries, rather than model instances, when used as an iterable. Each of those dictionaries represents an object, with the keys corresponding to the attribute names of model objects.

values()

Reference QuerySet API reference QuerySet APIMethods that return new QuerySets

For example: When using values() together with distinct(), be aware that ordering can affect the results. See the note in distinct() for details.

update()

Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets

update(**kwargs) aupdate(**kwargs) Asynchronous version: aupdate() Performs an SQL update query for the specified fields, and returns the number of rows matched (which may not be equal to the number of rows updated if some rows already have the new value).

Field options

Topic guide Models Fields

Each field takes a certain set of field-specific arguments (documented in the model field reference). For example, CharField (and its subclasses) require a max_length argument which specifies the size of the VARCHAR database field used to store the data.

Topic guide Models FieldsRelationships

To define a many-to-many relationship, use ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model. ManyToManyField requires a positional argument: the class to which the model is related.

1.10

Internals Django Deprecation Timeline

See the Django 1.8 release notes for more details on these changes. Support for calling a SQLCompiler directly as an alias for calling its quote_name_unless_alias method will be removed.

ModelAdmin options

Reference The Django admin site ModelAdmin objects

ModelAdmin.prepopulated_fields : Set prepopulated_fields to a dictionary mapping field names to the fields it should prepopulate from: ModelAdmin.preserve_filters : By default, applied filters are preserved on the list view after creating, editing, or deleting an object.

C

Index

| | | | --- | --- | | - cache - template tag - cache_control() (in module django.views.decorators.cache) - cache_key_prefix (backends.cached_db.SessionStore attribute) - CACHE_MIDDLEWARE_ALIAS - setting - CACHE_MIDDLEWARE_KEY_PREFIX - setting - CACHE_MIDDLEWARE_SECONDS - setting - cached.Loader (class in django.template.loaders) …

Bugfixes

Release notes Django 2.2.11 release notes

Fixed a data loss possibility in the select_for_update(). When using related fields or parent link fields with Multi-table inheritance in the of argument, the corresponding models were not locked (#31246).

Bugfixes

Release notes Django 2.2.16 release notes

Fixed a data loss possibility in the select_for_update(). When using related fields pointing to a proxy model in the of argument, the corresponding model was not locked (#31866).

Bugfixes

Release notes Django 3.0.10 release notes

Fixed a data loss possibility in the select_for_update(). When using related fields pointing to a proxy model in the of argument, the corresponding model was not locked (#31866).

Features removed in 1.10

Release notes Django 1.10 release notes

django.shortcuts.render() django.template.Context() django.template.RequestContext() django.template.response.TemplateResponse() The dictionary and context_instance parameters for the following functions are removed: django.shortcuts.render() django.shortcuts.render_to_response() django.template.loader.render_to_string() The dirs parameter for the following functions is removed: django.template.loader.get_template() django.template.loader.select_template() django.shortcuts.render() django.shortcuts.render_to_response() Session verification is enabled regardless of whether or not …

Bugfixes

Release notes Django 3.0.4 release notes

Fixed a data loss possibility when using caching from async code (#31253). Fixed a regression in Django 3.0 that caused a file response using a temporary file to be closed incorrectly (#31240). Fixed a data loss possibility in the select_for_update().

django.contrib.gis

Release notes Django 1.8 release notes Backwards incompatible changes in 1.8

A new GeoJSON serializer is now available. It is now allowed to include a subquery as a geographic lookup argument, for example City.objects.filter(point__within=Country.objects.filter(continent='Africa').values('mpoly')). The SpatiaLite backend now supports Collect and Extent aggregates when the database version is 3.0 or later.