from django.shortcuts import render

# Create your views here.

from django.shortcuts import render

from fb.models import UserPost


def index(request):
    if request.method == 'GET':
        posts = UserPost.objects.all()
        context = {
            'posts': posts,
        }
        return render(request, 'index.html', context)

Write the first view - news feed.
Write the first view - news feed.

  from django.shortcuts import render
  
- # Create your views here.
+ from fb.models import UserPost
  
+ 
+ def index(request):
+     if request.method == 'GET':
+         posts = UserPost.objects.all()
+         context = {
+             'posts': posts,
+         }
+         return render(request, 'index.html', context)
+ 
Write the first view - news feed.
## Code Before:
from django.shortcuts import render

# Create your views here.

## Instruction:
Write the first view - news feed.
## Code After:
from django.shortcuts import render

from fb.models import UserPost


def index(request):
    if request.method == 'GET':
        posts = UserPost.objects.all()
        context = {
            'posts': posts,
        }
        return render(request, 'index.html', context)
