django电子邮件未发送使用表格

问题描述

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)

我填写表格时没有任何错误,但首先页面没有按照提示重定向到/ contact,但是当我尝试使用shell时,它会起作用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)