1
0
mirror of https://github.com/django/django.git synced 2025-10-26 23:26:08 +00:00

[1.10.x] Fixed #26987 -- Documented using QuerySet.get() without arguments.

Backport of f3b601f11a from master
This commit is contained in:
Abhishek Bera
2016-08-19 23:51:33 +05:30
committed by Tim Graham
parent 33783a9e06
commit a77d979cbd

View File

@@ -1624,6 +1624,11 @@ The :exc:`~django.db.models.Model.DoesNotExist` exception inherits from
except ObjectDoesNotExist:
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()``
~~~~~~~~~~~~