summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-05-14 19:06:31 -0400
committerTim Graham <timograham@gmail.com>2016-05-14 19:07:39 -0400
commitdbd72b850b487be37df2940d16697a2d57b73ac6 (patch)
tree30783948c9aeb6216d5a43a3a9919b1b00af6d13 /docs/ref/models
parent936a7df6520941e264f741766281fc00e4709a2d (diff)
[1.9.x] Refs #26021 -- Used hanging indentation in some doc examples.
Backport of e475e849703d937e158e75e7a6d9cb99090857f6 from master
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/querysets.txt13
1 files changed, 9 insertions, 4 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 92dbe803b6..1c488c7e33 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -931,8 +931,10 @@ For example, suppose you have these models::
toppings = models.ManyToManyField(Topping)
def __str__(self): # __unicode__ on Python 2
- return "%s (%s)" % (self.name, ", ".join(topping.name
- for topping in self.toppings.all()))
+ return "%s (%s)" % (
+ self.name,
+ ", ".join(topping.name or topping in self.toppings.all()),
+ )
and run::
@@ -1679,8 +1681,11 @@ This is meant as a shortcut to boilerplatish code. For example::
This pattern gets quite unwieldy as the number of fields in a model goes up.
The above example can be rewritten using ``get_or_create()`` like so::
- obj, created = Person.objects.get_or_create(first_name='John', last_name='Lennon',
- defaults={'birthday': date(1940, 10, 9)})
+ obj, created = Person.objects.get_or_create(
+ first_name='John',
+ last_name='Lennon',
+ defaults={'birthday': date(1940, 10, 9)},
+ )
Any keyword arguments passed to ``get_or_create()`` — *except* an optional one
called ``defaults`` — will be used in a :meth:`get()` call. If an object is