获取模板Python时出错

2024-04-26 18:50:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用pythondjango写下了这个代码来使用模板和获取错误。 我的Django版本:1.8.3

from django.shortcuts import render
from django.http import HttpResponse
from django.template.loader import get_template  
from django.template import Context 

def hello_template (request):
    name = "Jatin"
    t = get_template('hello.html')
    html = t.render(Context({'name': name}, request))
    return HttpResponse(html)

错误:

AttributeError at /hello_template/

'str' object has no attribute 'copy'

Tags: django代码namefromimporthellogetrequest