[1.10.x] Fixed #26987 -- Documented using QuerySet.get() without arguments.
Backport of f3b601f11a
from master
This commit is contained in:
parent
33783a9e06
commit
a77d979cbd
|
@ -1624,6 +1624,11 @@ The :exc:`~django.db.models.Model.DoesNotExist` exception inherits from
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
print("Either the entry or blog doesn't exist.")
|
print("Either the entry or blog doesn't exist.")
|
||||||
|
|
||||||
|
If you expect a queryset to return one row, you can use ``get()`` without any
|
||||||
|
arguments to return the object for that row::
|
||||||
|
|
||||||
|
entry = Entry.objects.filter(...).exclude(...).get()
|
||||||
|
|
||||||
``create()``
|
``create()``
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue