Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

login_required

@login_required(login_url='login')
def upload_post(request):
    if request.method == 'POST':
        form = PostForm(request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, "Book added successfully")
        return redirect("index")
    else:
        form = PostForm()

    return render(request, 'blog/article_form.html', {"form": form})
Comment

login required

from django.contrib.auth.mixins import LoginRequiredMixin
Comment

PREVIOUS NEXT
Code Example
Python :: run pyinstaller from python 
Python :: google youtuve api python 
Python :: select multi columns pandas 
Python :: numpy datatime object 
Python :: leetcode python 
Python :: python how to create a class 
Python :: django password hashers 
Python :: imshow of matplotlib 
Python :: youtube mp3 downloader python 
Python :: polls/models.py 
Python :: variables in python 
Python :: split rows into multiple columns in pandas 
Python :: dictionary with list as values 
Python :: f string 
Python :: pybase64 
Python :: depth first search 
Python :: cmap seaborn 
Python :: how to activate venv python 
Python :: if queryset is empty django 
Python :: dot product of two vectors python 
Python :: python search list 
Python :: how to add number in tuple 
Python :: simulation? 
Python :: sys python 
Python :: django serializer method field read write 
Python :: python list of paths 
Python :: python string: indexing and slicing string 
Python :: printing a varible with a varible. python 
Python :: Third step creating python project 
Python :: star question in pyton 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =