﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28113	send_email module needs a name field	kinganu	nobody	"Hi, trying to create a basic contact page with django has been horrendous.  what took me 30 minutes to do in flask takes me 3 hours to do in django and still doesnt work.  

Why cant I add my own fields to a contact form?  Why would a contact form ever NOT have a name field?   Makes 0 sense to me...

I cannot send an email with a name variable, which blows my mind.  WTForms beats django forms any day, because its actually flexible.  Now I have to waste more time figuring out how to file a suggestion for django and fill this out. WOW...........pardon my frustration 


{{{
class ContactForm(forms.Form):
	name = forms.CharField(required=True, max_length=30)
	from_email = forms.EmailField(required=True)
	subject = forms.CharField(required=True, max_length=50)
	message = forms.CharField(widget=forms.Textarea, required=True, max_length=800)

def contact(request):
    if request.method == 'GET':
        form = ContactForm()
    else:
        form = ContactForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            subject = form.cleaned_data['subject']
            from_email = form.cleaned_data['from_email']
            message = form.cleaned_data['message']

        try:
            recipients = ['skyldev1@gmail.com']
            send_mail(name, subject, message, from_email, recipients)
        except BadHeaderError:
            return HttpResponse('Invalid header found.')
        return redirect('index')

    return render(request, ""home/contact.html"", {'form': form})
}}}
"	Uncategorized	closed	Forms	1.11	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
