1@login_required(login_url='login')
2def upload_post(request):
3 if request.method == 'POST':
4 form = PostForm(request.POST)
5 if form.is_valid():
6 form.save()
7 messages.success(request, "Book added successfully")
8 return redirect("index")
9 else:
10 form = PostForm()
11
12 return render(request, 'blog/article_form.html', {"form": form})