Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

createview django

# Required imports
from django.urls import reverse_lazy

class YourView(CreateView):
	model 			= Model
    fields 			= ['your_fields']
    template_name 	= 'your_template'
    success_url		= reverse_lazy('home')
    
    def form_valid(self, form):
        form.instance.user = self.request.user
        super(YourView, self).form_valid(form)
        return redirect('home')
Comment

Django Create View

class AuthorCreateView(CreateView):
    form_class = AuthorForm
    template_name = 'author_new.html'
    success_url = 'success'
Comment

PREVIOUS NEXT
Code Example
Python :: write file with python 
Python :: how to make python remove the duplicates in list 
Python :: python range backward 
Python :: python find word in list 
Python :: classes in python with self parameter 
Python :: como deixar todas as letras maiusculas no python 
Python :: How do you print multiple things on one statement in Python? 
Python :: say command python 
Python :: binomial coefficient python 
Python :: python split on first occurrence 
Python :: how to get a row from a dataframe in python 
Python :: python config file 
Python :: calculate integral python 
Python :: python write to file csv 
Python :: django filter text first character upper case 
Python :: limpiar consola en python 
Python :: install python selenium webdriver 
Python :: round python 
Python :: python progress bar console 
Python :: format percentage python 
Python :: json indent options python 
Python :: python version kali linux 
Python :: swapcase 
Python :: python type hint for a string 
Python :: blender python get selected object 
Python :: add element to list python at index 
Python :: pandas print all columns 
Python :: python testing machine learning 
Python :: install hydra python 
Python :: set cookie in python requests 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =