Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialArmendi Gjinolli
489 PointsDjango send_email Error while using forms, Where is the problem ?
I have an Error while using send_mail in a form. Here's the code:
def SuggestionView(request):
form = forms.SuggestionForm()
if request.method == 'POST':
form = forms.SuggestionForm(request.POST)
if form.is_valid():
send_mail(
'Suggestion from {}'.format(form.cleaned_data['name']),
form.cleaned_data['name']),
'[name] <{email}>'.format(**form.cleaned_data),
['andiigela12@gmail.com']
)
messages.add_message(request,messages.SUCCESS, 'Thanks for your suggestion.')
return HttpResponseRedirect(reverse('suggest'))
return render(request,'suggestion.html',{'form':form})
from django import forms
class SuggestionForm(forms.Form):
name = forms.CharField()
email = forms.EmailField()
suggestion = forms.CharField(widget=forms.Textarea)
MOD: I added formatting to the code to make it easier for people to read. See the Markdown Cheatsheet below the text box for how to do this. Thanks!