【发布时间】:2023-03-07 05:08:01
【问题描述】:
我需要在使用 django 时获取上下文 但我做不到
这是我的代码 在我的 jsx 中
<h1>{{titulo}}</h1>
<h2>{{ejemplo}}</h2>
在我的模板中:
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body >
<div id="app"></div>
<script type="text/javascript" src="{% static 'bundle.js' %}"></script>
</body>
</html>
在我看来py:
def registro (request,giro):
reg = 'Registro Normal'
if giro==1:
reg='Registro Especial'
context = {
'ejemplo':'tests',
'titulo':reg
}
return render(request,'home/registro.html',context)
但不渲染并出现错误:(
未捕获的引用错误:未定义标题
【问题讨论】: