from django import forms
from django.core.mail import send_mail
from django.conf import settings


class ContactForm(forms.Form):

    name = forms.CharField(label='Nome', required=True)
    email = forms.EmailField(label='E-mail')
    message = forms.CharField(label='Mensagem', widget=forms.Textarea(),
                              required=True)

    def send_mail(self):
        name = self.cleaned_data['name']
        email = self.cleaned_data['email']
        message = self.cleaned_data['message']
        message = 'Nome: {0}\nE-mail:{1}\n{2}'.format(name, email, message)
        send_mail(
                    'Contato Django E-commerce',
                    message,
                    settings.DEFAULT_FROM_EMAIL,
                    [settings.DEFAULT_FROM_EMAIL]
        )

[(8, 'django.forms.CharField', 'forms.CharField', False, 'from django import forms\n'), (9, 'django.forms.EmailField', 'forms.EmailField', False, 'from django import forms\n'), (18, 'django.core.mail.send_mail', 'send_mail', False, 'from django.core.mail import send_mail\n'), (10, 'django.forms.Textarea', 'forms.Textarea', False, 'from django import forms\n')]