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>

 

GitHub: https://github.com/Sokhavuth/khmerweb-django

Heroku: https://khmerweb-django.herokuapp.com