【发布时间】:2015-09-23 20:52:39
【问题描述】:
我不断收到错误 在此特定行中的“分配前引用的局部变量'form_message'”: " form_full_name,"
这是我在 django 1.8 中的代码:
def contact(request):
form = ContactForm(request.POST or None)
if form.is_valid():
form_full_name = form.cleaned_data.get("full_name")
form_email = form.cleaned_data.get("email")
form_message = form.cleaned_data.get("message")
subject = 'Site contact form'
from_email = settings.EMAIL_HOST_USER
to_email = [from_email]
contact_message = "%s: %s via %s"%(
form_full_name,
form_message,
form_email)
send_mail(subject,
contact_message,
from_email,
to_email,
fail_silently=False)
context = {
"form": form,
}
return render(request, "forms.html", context)
【问题讨论】:
标签: django python-2.7 django-forms django-views