django电子邮件未发送(使用表单)
当我填写表单时,我没有收到任何错误,但首先页面没有按照说明重定向到/contact,但是当我尝试使用shell时,它可以工作您确定django电子邮件未发送(使用表单),django,django-email,Django,Django Email,当我填写表单时,我没有收到任何错误,但首先页面没有按照说明重定向到/contact,但是当我尝试使用shell时,它可以工作您确定表单是否有效()返回True?@ArakkalAbu是的,没有错误集默认=False,然后重试。也许你会得到一些errors@ArakkalAbu仍然没有错误 from django.http import HttpResponse, HttpResponseRedirect from .forms import Contact from django.core.m
表单是否有效()
返回True
?@ArakkalAbu是的,没有错误集默认=False
,然后重试。也许你会得到一些errors@ArakkalAbu仍然没有错误
from django.http import HttpResponse, HttpResponseRedirect
from .forms import Contact
from django.core.mail import send_mail
def contact(response):
if response.method=="POST":
form= Contact(response.POST)
if form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
comment = form.cleaned_data['comment']
subject= "COMMENTS"
send_mail(subject,comment,email,['nafiyadargaw360@gmail.com'],fail_silently=True)
return HttpResponseRedirect("/contact")
else:
form=Contact()
context = {'form': form}
template = 'contact/index.html'
return render(response,template,context)