Reference QuerySet API reference
For datetime and time fields, an exact hour match. Allows chaining additional field lookups. Takes an integer between 0 and 23.
1413 sections across all versions Narrow to Django 6.0 (current) →
Reference QuerySet API reference
For datetime and time fields, an exact hour match. Allows chaining additional field lookups. Takes an integer between 0 and 23.
Reference QuerySet API reference
For datetime and time fields, an exact minute match. Allows chaining additional field lookups. Takes an integer between 0 and 59.
Reference QuerySet API reference
For datetime and time fields, an exact second match. Allows chaining additional field lookups. Takes an integer between 0 and 59.
Reference QuerySet API reference
Takes either True or False, which correspond to SQL queries of IS NULL and IS NOT NULL, respectively. Example: SQL equivalent:
Reference QuerySet API reference
Case-sensitive regular expression match. The regular expression syntax is that of the database backend in use.
Reference QuerySet API reference
Case-insensitive regular expression match. Example: SQL equivalents:
Reference QuerySet API reference QuerySet APIAggregation functions
Strings that reference fields on the model, transforms of the field, or query expressions.
Reference QuerySet API reference
An optional argument that represents the model field of the return value NOTE: When combining multiple field types, Django can only determine the > output_field if all fields are of the same type.
Reference QuerySet API reference
Keyword arguments that can provide extra context for the SQL generated by the aggregate.
Reference QuerySet API reference
classBitAnd(expression,filter=None,default=None,**extra)[source] : > NOTE: > > Added in version 6.1.
Reference QuerySet API reference
classBitOr(expression,filter=None,default=None,**extra)[source] : > NOTE: > > Added in version 6.1.
Reference QuerySet API reference
classBitXor(expression,filter=None,default=None,**extra)[source] : > NOTE: > > Added in version 6.1.
Reference QuerySet API reference
classCount(expression,distinct=False,filter=None,**extra)[source] : Returns the number of objects that are related through the provided expression. Count('*') is equivalent to the SQL COUNT(*) expression.
Reference QuerySet API reference
This section provides reference material for query-related tools not documented elsewhere.
Reference QuerySet API reference
classQ[source] A Q() object represents an SQL condition that can be used in database-related operations. It’s similar to how an F() object represents the value of a model field or annotation. They make it possible to define and reuse conditions.
Reference QuerySet API reference QuerySet APIMethods that return new QuerySets
values_list(*fields,flat=False,named=False) This is similar to values() except that instead of returning dictionaries, it returns tuples when iterated over.
Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets
create(**kwargs) acreate(**kwargs) Asynchronous version: acreate() A convenience method for creating an object and saving it all in one step. Thus: and: are equivalent.
Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets
bulk_create(objs,batch_size=None,ignore_conflicts=False,update_conflicts=False,update_fields=None,unique_fields=None) abulk_create(objs,batch_size=None,ignore_conflicts=False,update_conflicts=False,update_fields=None,unique_fields=None) Asynchronous version: abulk_create() This method inserts the provided list of objects into the database in an efficient manner (generally only 1 query, no matter how many objects there are), and returns created objects as a list, in the …
Reference QuerySet API reference QuerySet APIMethods that do not return QuerySetsiterator()
Oracle and PostgreSQL use server-side cursors to stream results from the database without loading the entire result set into memory. The Oracle database driver always uses server-side cursors.
Reference QuerySet API reference QuerySet APIField lookups
Exact match. If the value provided for comparison is None, it will be interpreted as an SQL NULL (see isnull for more details).