In Jinja2 template language, to use any statement, we need to put that statement in between curly brackets like this {% statement %} . And all statement must be ended with {% endstatement %} .
#home/views.py
from django.shortcuts import render
# Create your views here.
def index(request):
kdict = {
'siteTitle':'Khmer Web',
'pageTitle': 'Home',
'message': '<b>ស្វាគមន៍មកកាន់ទំព័រដើម!</b>'
}
return render(request,'base.html',context={'data':kdict})
<!--home/templates/base.html-->
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>{{ data.siteTitle }} | {{ data.pageTitle }}</title>
<link rel="stylesheet" href="{% static 'styles/base.css' %}" />
<link rel="stylesheet" href="{% static 'fonts/setup.css' %}" />
<link rel="icon" href="{% static 'images/siteLogo.png' %}" />
</head>
<body>
<p>
{% if 'message' in data %}
{{ data.message|safe }}
{% else %}
<span>No message here!</span>
{% endif %}
</p>
</body>
</html>