小编Ann*_*ska的帖子

django - render_to_string无效

我是新手.但是,如果没有愚蠢的问题......这是我的.为什么我的电子邮件(在正文部分)不包含该消息?

这是我的脆皮代码:

message = render_to_string('contact_template.txt', {'contact_name':   contact_name, 'contact_email': contact_email, 'form_content': content}, context_instance=RequestContext(request))
email = EmailMessage("New contact form submission", message, "annadrybulska@gmail.com" +'', ['annadrybulska@gmail.com'], headers = {'Reply-To': contact_email })
email.send()
Run Code Online (Sandbox Code Playgroud)

我真的很感激任何帮助..从早上9点开始工作,但仍然没有...

我的模板(contact_template.txt),(我收到的所有电子邮件都包含此内容,但没有消息):

Contact Name:


Email:


Content:
Run Code Online (Sandbox Code Playgroud)

和我的观点:(我不得不说这是令人生畏的...)

from polls.forms import ContactForm
from django.core.mail import EmailMessage
from django.template import Context, Template, RequestContext
from django.shortcuts import render
from django.shortcuts import redirect
from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponse, HttpResponseRedirect
from django.template.loader import render_to_string, get_template

def index(request):
    return HttpResponse("Hello, world. You're at the …
Run Code Online (Sandbox Code Playgroud)

django

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

django ×1