Release notes Django 2.0 release notes
It may be helpful particularly when select_for_update() is used in conjunction with select_related(). The new field_name parameter of QuerySet.in_bulk() allows fetching results based on any unique model field.
257 sections in Django dev Search all versions →
Release notes Django 2.0 release notes
It may be helpful particularly when select_for_update() is used in conjunction with select_related(). The new field_name parameter of QuerySet.in_bulk() allows fetching results based on any unique model field.
Release notes Django 4.2.2 release notes
Fixed a regression in Django 4.2 that caused a serialization crash on a ManyToManyField without a natural key when its Manager’s base QuerySet used select_related() (#34620).
Release notes Django 5.1 release notes
QuerySet.explain() now supports the generic_plan option on PostgreSQL 16+. RowRange now accepts positive integers for the start argument and negative integers for the end argument.
Release notes Django 6.1.2 release notes
Fixed a bug in Django 6.1 where FETCH_PEERS did not batch instances loaded by select_related(), causing unnecessary queries (#37344).
Reference The Django admin site
ModelAdmin.raw_id_fields : By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey. Sometimes you don’t want to incur the overhead of having to select all the related instances to display in the drop-down.
Reference The Django admin site
InlineModelAdmin.max_num : This controls the maximum number of forms to show in the inline. This doesn’t directly correlate to the number of objects, but can if the value is small enough.
Tutorial Writing your first Django app, part 7
OK, we have our Question admin page, but a Question has multiple Choices, and the admin page doesn’t display choices. Yet. There are two ways to solve this problem.
Reference QuerySet API reference
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.
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
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.
Topic guide 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.
Reference QuerySet API reference
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.
Reference QuerySet API reference
For example: When using values() together with distinct(), be aware that ordering can affect the results. See the note in distinct() for details.
Reference QuerySet API reference
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).
Topic guide Models
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
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.
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.
Reference The Django admin site
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.
| | | | --- | --- | | - 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) …
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).