From cf2cd4053fe3eed50ab2b7269ed72d25712c970a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 22 Aug 2016 19:22:04 -0400 Subject: [PATCH] Fixed #27104 -- Corrected shell example in tutorial 5. --- docs/intro/tutorial05.txt | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/docs/intro/tutorial05.txt b/docs/intro/tutorial05.txt index 3f56166ed4..438cb20045 100644 --- a/docs/intro/tutorial05.txt +++ b/docs/intro/tutorial05.txt @@ -343,7 +343,9 @@ which will allow us to examine some additional attributes on responses such as ``response.context`` that otherwise wouldn't be available. Note that this method *does not* setup a test database, so the following will be run against the existing database and the output may differ slightly depending on what -questions you already created. +questions you already created. You might get unexpected results if your +``TIME_ZONE`` in ``settings.py`` isn't correct. If you don't remember setting +it earlier, check it before continuing. Next we need to import the test client class (later in ``tests.py`` we will use the :class:`django.test.TestCase` class, which comes with its own client, so @@ -367,23 +369,11 @@ With that ready, we can ask the client to do some work for us:: >>> response.status_code 200 >>> response.content - b'\n\n\n

No polls are available.

\n\n' - >>> # note - you might get unexpected results if your ``TIME_ZONE`` - >>> # in ``settings.py`` is not correct. If you need to change it, - >>> # you will also need to restart your shell session - >>> from polls.models import Question - >>> from django.utils import timezone - >>> # create a Question and save it - >>> q = Question(question_text="Who is your favorite Beatle?", pub_date=timezone.now()) - >>> q.save() - >>> # check the response once again - >>> response = client.get('/polls/') - >>> response.content - b'\n\n\n \n\n' + b'\n \n\n' >>> # If the following doesn't work, you probably omitted the call to >>> # setup_test_environment() described above >>> response.context['latest_question_list'] - ]> + ]> Improving our view ------------------