Gaining information from the form data in form_valid
<p>I have to get some information from the form that has just been submitted. The form is a to put an event on a calendar.</p>

<p>I need to get the "Category" field, this is basically a name of the person the event includes.</p>

<p>From there I need to split the name into last and first and get their email from the user table. From there I will send them a email telling them they have been added to the calendar.</p>

<p>This is my <code>form_valid</code> function now: </p>

<pre><code>def form_valid(self, form):
    Event = form.save(commit=False)
    Event.created_by = self.request.user
    Event.save()
    send_mail(
        'test',
        'Is this really working?',
        'from@example.com',
        ['blah@gmail.com'],
        fail_silently=False,
    )
    return HttpResponseRedirect('/calendar/')
</code></pre>

<p>How do I get information that has just been submitted in the form? Is that even possible?</p>

<p>Well, you've just created a new Event instance with that data. So the data is in that Event, naturally.</p>

<p>You could also get it from the <code>form.cleaned_data</code> dict.</p>

python django django-forms