Problems configuring views using Jango

Asked

Viewed 45 times

0

I’m studying Jango and I’m having problems in the following part {'posts': posts} I’m using as ide pycharm and it shows error but for me the syntax of the code is correct.

from django.shortcuts import render
from django.utils import timezone
from .models import Post

def post_list(request): 
    Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') 
   return render(request, 'blog/post_list.html', {'posts' : posts})  
  • Its variable posts there is no.

1 answer

1


Trivial error:

def post_list(request): 
    posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') 
   return render(request, 'blog/post_list.html', {'posts' : posts}) 
  • Really thank you, careless my nor realized had not assigned posts.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.