the problem is on the return HttpResponse (t.render(c)) line. Check that your indentation is correct
On Aug 22, 9:51 am, craphunter <craphun...@yahoo.de> wrote: > Hi, > > I am very new in Django and Python. I am stucked in Tutorial 3 in part > "Write views that actually do something". > > I don't get it to run the index.html. > > I have copied: " > from django.template import Context, loader > from mysite.polls.models import Poll > from django.http import HttpResponse > > 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)) > " > in my views.py. > > My setting file looks like this: > "TEMPLATE_DIRS = ("/home/username/dtest/mysite/templates" > # Put strings here, like "/home/html/django_templates" or "C:/www/ > django/templates". > # Always use forward slashes, even on Windows. > # Don't forget to use absolute paths, not relative paths. > ) > > I get this answer if I type this in my browser "http://127.0.0.1:8000/ > polls": > > File "/home/username/dtest/mysite/../mysite/polls/views.py", line 13 > > return HttpResponse(t.render(c)) > > SyntaxError: 'return' outside function > > What is wrong? > > Thanks for help!!! > > Craphunter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.