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 :: python apply function to dictionary values 
Python :: python csv 
Python :: how to do md5 hASH IN PYTHON 
Python :: how to sort dictionary in python by lambda 
Python :: python os remove extension 
Python :: python find index of minimum in list 
Python :: plt change grid color 
Python :: if list item is found in string get that item python 
Python :: post request in python flaks 
Python :: python code to remove file extension 
Python :: Efficiently count zero elements in numpy array? 
Python :: double for in python 
Python :: Getting the Current Working Directory in Python 
Python :: pi in python math 
Python :: selenium python class contains 
Python :: how to commenbt code in python 
Python :: python undefine variable 
Python :: how to restart program in python 
Python :: first 5 letters of a string python 
Python :: python3 send mail 
Python :: time.perf_counter 
Python :: basemap python 
Python :: python get response from url 
Python :: root template 
Python :: python naming conventions 
Python :: how to delete all item in treeview tkinter 
Python :: how to flatten a nested list in python 
Python :: reverse geocode python 
Python :: runge kutta 
Python :: except python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =