From 70b05c53745e4386fb1197c419fe15c6cc65f878 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 23 Nov 2021 07:04:04 +0100 Subject: [PATCH] [4.0.x] Corrected signatures of QuerySet's methods. Backport of a17becf4c7f4e4057e8c94990e4b4999be0aea95 from main --- docs/ref/models/querysets.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index fa11555271..484d8b4ff7 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -179,7 +179,7 @@ executed. ``filter()`` ~~~~~~~~~~~~ -.. method:: filter(**kwargs) +.. method:: filter(*args, **kwargs) Returns a new ``QuerySet`` containing objects that match the given lookup parameters. @@ -189,12 +189,12 @@ The lookup parameters (``**kwargs``) should be in the format described in underlying SQL statement. If you need to execute more complex queries (for example, queries with ``OR`` statements), -you can use :class:`Q objects `. +you can use :class:`Q objects ` (``*args``). ``exclude()`` ~~~~~~~~~~~~~ -.. method:: exclude(**kwargs) +.. method:: exclude(*args, **kwargs) Returns a new ``QuerySet`` containing objects that do *not* match the given lookup parameters. @@ -231,7 +231,7 @@ In SQL terms, that evaluates to: Note the second example is more restrictive. If you need to execute more complex queries (for example, queries with ``OR`` statements), -you can use :class:`Q objects `. +you can use :class:`Q objects ` (``*args``). ``annotate()`` ~~~~~~~~~~~~~~ @@ -1851,7 +1851,7 @@ raised if ``select_for_update()`` is used in autocommit mode. ``raw()`` ~~~~~~~~~ -.. method:: raw(raw_query, params=(), translations=None) +.. method:: raw(raw_query, params=(), translations=None, using=None) Takes a raw SQL query, executes it, and returns a ``django.db.models.query.RawQuerySet`` instance. This ``RawQuerySet`` instance @@ -1923,7 +1923,7 @@ they query the database each time they're called. ``get()`` ~~~~~~~~~ -.. method:: get(**kwargs) +.. method:: get(*args, **kwargs) Returns the object matching the given lookup parameters, which should be in the format described in `Field lookups`_. You should use lookups that are @@ -1931,7 +1931,7 @@ guaranteed unique, such as the primary key or fields in a unique constraint. For example:: Entry.objects.get(id=1) - Entry.objects.get(blog=blog, entry_number=1) + Entry.objects.get(Q(blog=blog) & Q(entry_number=1)) If you expect a queryset to already return one row, you can use ``get()`` without any arguments to return the object for that row::