0
我有我的views.py
这种方法:问题 - Django的1.6
def contact_us(request):
form = ContactUsForm()
d = {'form': form}
if request.method == 'POST':
form = ContactUsForm(request.POST)
if form.is_valid():
Contact.objects.create(
first_name=form.cleaned_data['first_name'],
last_name=form.cleaned_data['last_name'],
email=form.cleaned_data['email'],
message=form.cleaned_data['message'],
)
try:
send_mail(first_name,last_name,email,message,['[email protected]'])
except BadHeaderError:
return HttpResponse('Invalid header found.')
d['message'] = _('Thank You! We will contact you shortly')
else:
d['form'] = form
return render_to_response('profiles/contact_us.html', d,
context_instance=RequestContext(request))
这是网址:
http://beta.contratalos.com/profiles/contact_us/
我想发送消息到我在sned_mail
方法中指定了收件人。
但每次我尝试它抛出这个错误:
NameError: global name 'first_name' is not defined
File "apps/profiles/views.py", line 737, in contact_us
send_mail(first_name,last_name,email,message,['[email protected]'])
什么,可能是任何想法?
在此先感谢!
谢谢Siddhart,但现在说:Asse田:“到”参数必须是一个列表或元组=( – NeoVe
我认为你正在使用的send_mail的方式不正确send_mail(“主题在这里”,“这里就是信息。“‘[email protected]’, [” [email protected]'],fail_silently = FALSE) –
和田野?我的意思是,应该把这些字段的数据,我只是这个代替它呢? – NeoVe