login required

Solutions on MaxInterview for login required by the best coders in the world

showing results for - "login required"
Jared
24 Apr 2020
1from django.contrib.auth.mixins import LoginRequiredMixin
Matías
05 Jan 2021
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})