render_to_string快捷函数,渲染模板字符串

# views.py
from django.template.loader import render_to_string
from django.http import HttpResponse
def index(request):
  template_str =render_to_string(
    'email.html',
    context=job_info
  )
  return HttpReponse(template_str )

# email.html
Job:[{{job_id}}] {{job_name}} {{status}}

posted @ 2022-09-14 21:29  我在路上回头看  阅读(104)  评论(0编辑  收藏  举报