Reference QuerySet API reference
earliest(*fields) aearliest(*fields) Asynchronous version: aearliest() Works otherwise like latest() except the direction is changed.
1413 sections across all versions Narrow to Django 6.0 (current) →
Reference QuerySet API reference
earliest(*fields) aearliest(*fields) Asynchronous version: aearliest() Works otherwise like latest() except the direction is changed.
Reference QuerySet API reference
first() afirst() Asynchronous version: afirst() Returns the first object matched by the queryset, or None if there is no matching object.
Reference QuerySet API reference
last() alast() Asynchronous version: alast() Works like first(), but returns the last object in the queryset.
Reference QuerySet API reference
aggregate(*args,**kwargs) aaggregate(*args,**kwargs) Asynchronous version: aaggregate() Returns a dictionary of aggregate values (averages, sums, etc.) calculated over the QuerySet. Each argument to aggregate() specifies a value that will be included in the dictionary that is returned.
Reference QuerySet API reference
exists() aexists() Asynchronous version: aexists() Returns True if the QuerySet contains any results, and False if not.
Reference QuerySet API reference
contains(obj) acontains(obj) Asynchronous version: acontains() Returns True if the QuerySet contains obj, and False if not. This tries to perform the query in the simplest and fastest way possible.
Reference QuerySet API reference
… here we update the comments_on and headline fields: The update() method is applied instantly, and the only restriction on the QuerySet that is updated is that it can only update columns in the model’s main table, not on related models. …
Reference QuerySet API reference
delete() adelete() Asynchronous version: adelete() Performs an SQL delete query on all rows in the QuerySet and returns the number of objects deleted and a dictionary with the number of deletions per object type.
Reference QuerySet API reference
classmethodas_manager() Class method that returns an instance of Manager with a copy of the QuerySet’s methods. See Creating a manager with QuerySet methods for more details.
Reference QuerySet API reference
explain(format=None,**options) aexplain(format=None,**options) Asynchronous version: aexplain() Returns a string of the QuerySet’s execution plan, which details how the database would execute the query, including any indexes or joins that would be used.
Reference QuerySet API reference
They’re specified as keyword arguments to the QuerySet methods filter(), exclude() and get(). For an introduction, see models and database queries documentation. Django’s built-in lookups are listed below. It is also possible to write custom lookups for model fields.
Reference QuerySet API reference
In a given iterable; often a list, tuple, or queryset. It’s not a common use case, but strings (being iterables) are accepted.
Reference QuerySet API reference
Attempts to use > aggregation on date/time fields in SQLite will raise NotSupportedError. NOTE: Aggregation functions return None when used with an empty QuerySet > or group.
Reference QuerySet API reference
An optional argument that allows specifying a value to use as a default value when the queryset (or grouping) contains no entries.
Reference QuerySet API reference
classAnyValue(expression,output_field=None,filter=None,default=None,**extra)[source] : Returns an arbitrary value from the non-null input values.
Reference QuerySet API reference
classAvg(expression,output_field=None,distinct=False,filter=None,default=None,**extra)[source] : Returns the mean value of the given expression, which must be numeric unless you specify a different output_field.
Reference QuerySet API reference
classMax(expression,output_field=None,filter=None,default=None,**extra)[source] : Returns the maximum value of the given expression.
Reference QuerySet API reference
classMin(expression,output_field=None,filter=None,default=None,**extra)[source] : Returns the minimum value of the given expression.
Reference QuerySet API reference
classStdDev(expression,output_field=None,sample=False,filter=None,default=None,**extra)[source] : Returns the standard deviation of the data in the provided expression.
Reference QuerySet API reference
classSum(expression,output_field=None,distinct=False,filter=None,default=None,**extra)[source] : Computes the sum of all values of the given expression.