Saturday, 15 August 2015

Django Error "Caught SyntaxError while rendering: invalid syntax " -



Django Error "Caught SyntaxError while rendering: invalid syntax " -

i'm creating django app via tutorial https://docs.djangoproject.com/en/dev/intro/tutorial04/ i'm trying access admin page display error don't know how fix.

templatesyntaxerror @ /admin/ caught syntaxerror while rendering: invalid syntax (views.py, line 34)request method: request url: http://cat.pythonanywhere.com/admin/ django version: 1.3.5 exception type: templatesyntaxerror exception value: caught syntaxerror while rendering: invalid syntax (views.py, line 34) exception location: /home/cat/mysite/myapp/urls.py in <module>, line 2 python executable: /usr/local/bin/uwsgi python version: 2.7.3 python path: ['/var/www',

my views.py :

from django.http import httpresponse ,httpresponseredirect mysite.myapp.models import poll django.http import http404 django.template import context, loader django.shortcuts import render, get_object_or_404 django.core.urlresolvers import reverse polls.models import choice, poll def index(request): homecoming httpresponse("hello, world. you're @ poll index.") def detail(request, poll_id): homecoming httpresponse("you're looking @ poll %s." % poll_id) def results(request, poll_id): homecoming httpresponse("you're looking @ results of poll %s." % poll_id) def vote(request, poll_id): p = get_object_or_404(poll, pk=poll_id) try: selected_choice = p.choice_set.get(pk=request.post['choice']) except (keyerror, choice.doesnotexist): # redisplay poll voting form. homecoming render(request, 'myapp/detail.html', { 'poll': p, 'error_message': "you didn't select choice.", }) else: selected_choice.votes += 1 selected_choice.save() # homecoming httpresponseredirect after dealing # post data. prevents info beingness posted twice if # user hits button. homecoming httpresponseredirect(reverse('myapp:results', args=(p.id,)))) def index(request): latest_poll_list = poll.objects.order_by('-pub_date')[:5] template = loader.get_template('myapp/index.html') context = context({ 'latest_poll_list': latest_poll_list, }) homecoming httpresponse(template.render(context)) def detail(request, poll_id): poll = get_object_or_404(poll, pk=poll_id) homecoming render(request, 'myapp/detail.html', {'poll': poll}) def results(request, poll_id): poll = get_object_or_404(poll, pk=poll_id) homecoming render(request, 'myapp/results.html', {'poll': poll})

line 34 here

homecoming httpresponseredirect(reverse('myapp:results', args=(p.id,))))

can please help me!

homecoming httpresponseredirect(reverse('results', args=p.id))

django syntax

No comments:

Post a Comment