I have this view in my app:
我的应用程序中有这个视图:
def contact(request):
form_class = ContactForm
if request.method == 'POST':
form = form_class(data=request.POST)
if form.is_valid():
contact_name = form.cleaned_data['contact_name']
contact_email = form.cleaned_data['contact_email']
contact_website = form.cleaned_data['contact_website']
contact_subject = form.cleaned_data['contact_subject']
form_content = form.cleaned_data['content']
template = get_template('contact/contact_template.txt')
context = Context({'contact_name': contact_name,
'contact_email': contact_email,
'contact_website': contact_website,
'contact_subject': contact_subject,
'form_content': form_content, })
content = template.render(context)
email = EmailMessage(
"New contact form submission",
content,
"www.inexistente.com" + '<[email protected]>',
['[email protected]'],
headers={'Reply-To': contact_email}
)
email.send()
return redirect('/')
return render(request, 'contact/contact.html', {'form': form_class, })
d