hello Fidel Leon can you please rewrite the whole views.py code so that i can understand what is the exact code is
On Thu, May 3, 2018 at 9:19 PM, Fidel Leon <fi...@flm.cat> wrote: > > > El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah (< > avitabay...@gmail.com>) escribió: > >> >> *polls/views.py*: >> >> from django.http import HttpResponse >> from django.template import loader >> >> from . models import Question >> >> def index(request): >> return HttpResponse("Hello, world.You're at the polls index.") >> latest_question_list = Question.objects.order_by('-pub_date')[:5] >> output = ', '.join([q.question_text for q in latest_question_list]) >> return HttpResponse(output) >> latest_question_list = Question.objects.order_by('-pub_date')[:5] >> template = loader.get_template('polls/index.html') >> context = { >> 'latest_question_list': latest_question_list, >> } >> return HttpResponse(template.render(context, request)) >> >> > Your function index(request) inside polls/views.py is badly written (you > have three function returns). Seems you are following the tutorial but not > removing the previous examples: > > def index(request): > latest_question_list = Question.objects.order_by('-pub_date')[:5] > context = {'latest_question_list': latest_question_list} > return render(request, 'polls/index.html', context) > > -- > Fidel Leon > fi...@flm.cat > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/django-users/5hvN4Lfds-w/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa > 4vTbL92BQf5CHg-Nw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEx5wm7VMMa3C2%3DyWA%3DQu%3DhihJiWujwvoA59Xx4ru59Zdc0UVg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.