1👍
✅
You can override CreateView().post()
and UpdateView().post()
methods like this
class CreatePost(CreateView):
model = post
fields = ['title', 'content']
def post(self, request, *args, **kwargs):
# Get your data from post request eg. request.POST['mykey']
return redirect('success_page')
class UpdatePost(UpdateView):
model = post
fields = ['title', 'content']
def post(self, request, *args, **kwargs):
# Get your data from post request eg. request.POST['mykey']
return redirect('success_page')
Note : You’ve created your post model class in lowercase which is not good practice always name a class in CapWords. Because you have written your class in lowercase python will treat your post class as a post method or it may lead to logical error.
Source:stackexchange.com