Explorar el Código

Fixed #26987 -- Documented using QuerySet.get() without arguments.

Abhishek Bera hace 8 años
padre
commit
f3b601f11a
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      docs/ref/models/querysets.txt

+ 5 - 0
docs/ref/models/querysets.txt

@@ -1671,6 +1671,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()``
 ~~~~~~~~~~~~