Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#28113 closed Uncategorized (needsinfo)

send_email module needs a name field

Reported by: kinganu Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by kinganu)

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})

Change History (5)

comment:1 by kinganu, 8 years ago

Description: modified (diff)

comment:2 by kinganu, 8 years ago

Description: modified (diff)

comment:3 by kinganu, 8 years ago

Description: modified (diff)

comment:4 by Aymeric Augustin, 8 years ago

Resolution: needsinfo
Status: newclosed

I understand that you're frustrated and I'm sorry Django doesn't work well for you. Perhaps you should stick with Flask or WTForms.

I also failed to spot a question in what you wrote. If you think there's a bug, please clarify where you think Django is at fault and why.

You say Why cant I add my own fields to a contact form? but you proceed to show a contact form with your own fields.

comment:5 by Tim Graham, 8 years ago

See also TicketClosingReasons/UseSupportChannels for ways to get help with usage questions.

Note: See TracTickets for help on using tickets.
Back to Top