views.py

>   def index(request):
>     latest_comic = Comic.objects.order_by('-comic_pub_date')[:2]
>
> This has an implicit .all(), it's the same than doing

Comic.objects.all().order_by('-comic_pub_date')[:2]

Then you are slicing it for the first 2 records, that's why you see 2
records. Use .first() instead the slicing to get only one record (or
slice 1, [:1] or [0]). Your template code also support several
elements, you should check it


>     context = {'latest_comic': latest_comic}
>     return HttpResponse(context)
>     # return render(request, 'futureFleet/index.html', context) This sends to 
> the template but doesn’t work at the moment
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CA%2BFDnh%2B6EWrryQE47qGAPZbvwEF0Zjt5oAS_4aukQQBe%2B8FzKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to