6👍
✅
You mean you need the values of the filled in form?
In your view, check if the form is valid using form.is_valid()
; this populates self.cleaned_data
containing your cleaned values. Using data isn’t all that safe without validating it first.
so:
views.py:
if request.method == 'post':
form = ContactForm(request.POST)
if form.is_valid():
form.send()
forms.py:
from django import forms
class ContactForm(forms.Form):
subject = forms.CharField(required=True)
message = forms.CharField(required=True, widget=forms.Textarea)
def send(self):
subject = self.cleaned_data['subject']
...
Source:stackexchange.com