Make a website with Django: Difference between revisions

Content added Content deleted
imported>Jesstess
imported>Jesstess
Line 52: Line 52:
* Please visit https://docs.djangoproject.com/en/1.4/intro/tutorial03/ and complete part 3 of the tutorial.
* Please visit https://docs.djangoproject.com/en/1.4/intro/tutorial03/ and complete part 3 of the tutorial.


<b>Check your understanding</b>: What does <code>api.GetSearch</code> return?
<b>Check your understanding</b>: Which of the following URL fragments matches this pattern from a sample <code>urls.py</code>?
<pre>r'^polls/(?P<poll_id>\d+)/results/$'</pre>


* polls/ABC/results/
* polls/12345/results/
* polls//results/

<b>Check your understanding</b>: What is the purpose of <code>t.render</code> in this code snippet?

<pre>def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('polls/index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))</pre>


=== 4. Complete Part 4 of the tutorial ===
=== 4. Complete Part 4 of the tutorial ===