我正在创建一个联系人页面,在该页面中向用户发送了电子邮件。当我访问联系人页面时,遇到错误“ / contact /名称'ContactForm'未定义的NameError”
有什么主意吗?
代码:
def Contact(request):
Contact_Form = ContactForm
if request.method == 'POST':
form = Contact_Form(data=request.POST)
if form.is_valid():
contact_name = request.POST.get('contact_name')
contact_email = request.POST.get('contact_email')
contact_content = request.POST.get('content')
template = get_template('/contact_form.txt')
context = {
'contact_name' : contact_name,
'contact_email' : contact_email,
'contact_content' : contact_content,
}
content = template.render(context)
email = EmailMessage(
"New contact form email",
content,
"Creative web" + '',
['servwishes@gmail.com'],
headers = { 'Reply To': contact_email }
)
enter code here
email.send()
return redirect('blog:success')
return render(request, 'users/contact.html', {'form':Contact_Form })