Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: can't load template index
    text
    copied!<p>i'm following the Django 1.5 tutorial: Writing your first Django app. In part 3, it teaches how to load a template called polls/index.html. It's supposed to show a bulleted-list containing "What's up", when i point to browser at "/polls/", but when I go to browser </p> <pre><code>http://localhost:8000/polls/ </code></pre> <p>, the page is just blank.</p> <p>here's my polls/urls.py</p> <pre><code>from django.conf.urls import patterns, url from polls import views urlpatterns = patterns('', # ex: /polls/ url(r'^$', views.index, name='index'), # ex: /polls/5/ url(r'^(?P&lt;poll_id&gt;\d+)/$', views.detail, name='detail'), # ex: /polls/5/results/ url(r'^(?P&lt;poll_id&gt;\d+)/results/$', views.results, name='results'), # ex: /polls/5/vote/ url(r'^(?P&lt;poll_id&gt;\d+)/vote/$', views.vote, name='vote'), ) </code></pre> <p>here's my polls/views.py</p> <pre><code># Create your views here. from django.http import HttpResponse from django.template import RequestContext, loader from polls.models import Poll def index(request): latest_poll_list = Poll.objects.order_by('-pub_date')[:5] template = loader.get_template('polls/index.html') context = RequestContext(request, { 'latest_poll_list': latest_poll_list, }) return HttpResponse(template.render(context)) def detail(request, poll_id): return HttpResponse("You're looking at poll %s." % poll_id) def results(request, poll_id): return HttpResponse("You're looking at the results of poll %s." % poll_id) def vote(request, poll_id): return HttpResponse("You're voting on poll %s." % poll_id) </code></pre> <p>here's my index.html's directory</p> <pre><code>mysite/polls/templates/polls/index.html </code></pre> <p>here's my index.html</p> <pre><code>{% if latest_poll_list %} &lt;ul&gt; {% for poll in latest_pol_list %} &lt;li&gt;&lt;a href="/polls/{{poll.id}}"&gt;{{ poll.question }}&lt;/a&gt;&lt;/li&gt; {% endfor %} &lt;/ul&gt; {% else %} &lt;p&gt;No polls are available.&lt;/p&gt; {% endif %} </code></pre> <p>Anyone have the same problem?</p> <p>THX!!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload