createview

Solutions on MaxInterview for createview by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "createview"
Maelyne
19 Apr 2016
1# Required imports
2from django.urls import reverse_lazy
3
4class YourView(CreateView):
5	model 			= Model
6    fields 			= ['your_fields']
7    template_name 	= 'your_template'
8    success_url		= reverse_lazy('home')
9    
10    def form_valid(self, form):
11        form.instance.user = self.request.user
12        super(YourView, self).form_valid(form)
13        return redirect('home')