createview

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

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')