0
from django.shortcuts import render
from  .models import Post

def post_list_view(request):
  post_objects = Post.objects.all()
  context = {
    'post_objects' : post_objects
  }
return  render(request, "posts/index.html", context)
U12-Forward
  • 65,118
  • 12
  • 70
  • 89

1 Answers1

1

The return should be inside the function. At the same indent than the rest of the function

from django.shortcuts import render
from  .models import Post

def post_list_view(request):
  post_objects = Post.objects.all()
  context = {
    'post_objects' : post_objects
  }
  return render(request, "posts/index.html", context)

JuR
  • 113
  • 4