Reputation: 4008
In a CreateView I have the following code:
def post(self, request, *args, **kwargs):
response = super().post(request, *args, **kwargs)
send_confirmation_email()
When a form is submited, I want to send an email, but in the email function, I need some data from the context(what was submitted).
Also I want this to happen if everything is ok, so also on get_success_url.
Upvotes: 0
Views: 123
Reputation: 34922
You are mixing two things. context_data
is the data you send to the template. You can get it with self.get_context_data()
if needed.
The submitted data can be found in self.request.POST
.
However, in a create view, you can use the form_valid()
method to process the form data.
Upvotes: 2