diff options
| author | Tim Graham <timograham@gmail.com> | 2015-10-05 19:07:34 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-10-06 12:38:34 -0400 |
| commit | e0837f2cb12de5e95e621d19b186b0da43bcdee2 (patch) | |
| tree | ea6ae0b150304ed18d93fb8c3ee3b7defbda0e26 /docs/intro/tutorial02.txt | |
| parent | 3543fec3b739864c52de0a116dde3b0e5e885799 (diff) | |
Fixed #25508 -- Modified QuerySet.__repr__() to disambiguate it from a list.
Diffstat (limited to 'docs/intro/tutorial02.txt')
| -rw-r--r-- | docs/intro/tutorial02.txt | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index fbf15e8d1b..1e3c1accf7 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -401,7 +401,7 @@ Once you're in the shell, explore the :doc:`database API </topics/db/queries>`:: # No questions are in the system yet. >>> Question.objects.all() - [] + <QuerySet []> # Create a new Question. # Support for time zones is enabled in the default settings file, so @@ -432,8 +432,7 @@ Once you're in the shell, explore the :doc:`database API </topics/db/queries>`:: # objects.all() displays all the questions in the database. >>> Question.objects.all() - [<Question: Question object>] - + <QuerySet [<Question: Question object>]> Wait a minute. ``<Question: Question object>`` is, utterly, an unhelpful representation of this object. Let's fix that by editing the ``Question`` model (in the @@ -494,14 +493,14 @@ Save these changes and start a new Python interactive shell by running # Make sure our __str__() addition worked. >>> Question.objects.all() - [<Question: What's up?>] + <QuerySet [<Question: What's up?>]> # Django provides a rich database lookup API that's entirely driven by # keyword arguments. >>> Question.objects.filter(id=1) - [<Question: What's up?>] + <QuerySet [<Question: What's up?>]> >>> Question.objects.filter(question_text__startswith='What') - [<Question: What's up?>] + <QuerySet [<Question: What's up?>]> # Get the question that was published this year. >>> from django.utils import timezone @@ -535,7 +534,7 @@ Save these changes and start a new Python interactive shell by running # Display any choices from the related object set -- none so far. >>> q.choice_set.all() - [] + <QuerySet []> # Create three choices. >>> q.choice_set.create(choice_text='Not much', votes=0) @@ -550,7 +549,7 @@ Save these changes and start a new Python interactive shell by running # And vice versa: Question objects get access to Choice objects. >>> q.choice_set.all() - [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] + <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> >>> q.choice_set.count() 3 @@ -560,7 +559,7 @@ Save these changes and start a new Python interactive shell by running # Find all Choices for any question whose pub_date is in this year # (reusing the 'current_year' variable we created above). >>> Choice.objects.filter(question__pub_date__year=current_year) - [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] + <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> # Let's delete one of the choices. Use delete() for that. >>> c = q.choice_set.filter(choice_text__startswith='Just hacking') |
