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)
Asked
Active
Viewed 41 times
0

U13-Forward
- 69,221
- 14
- 89
- 114
-
1Indent your `return` into your function... – U13-Forward Aug 17 '21 at 07:13
1 Answers
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