1👍
✅
You are calling the render
function at the bottom of your post_list
function. The third argument (context
) should be a dictionary but you are not passing that. So that line should probable be changed to something like:
def post_list(request):# Create your views here.
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'blog/post_list.html', {'posts': posts})
See that we are passing {'posts': posts}
here now. This tells django that it should pass posts
(which you defined one line above) to the template and make it accessible as something also called posts
there.
You can see that from the ValueError
that Django returns. It is expecting something of length two (a key and a value) but it gets something of length 5 (the string posts
).
Source:stackexchange.com