Filter in Jinja2 language is a kind of function able to modify the variable next to it. There are many predefined filters in Jinja2 template engine, and we do not need to use all of them.
#home/views.py
from django.shortcuts import render
# Create your views here.
def index(request):
kdict = {
'siteTitle':'Khmer Web',
'pageTitle': 'Home',
'message': 'ស្វាគមន៍មកកាន់ទំព័រដើម!'
}
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>{{ data.message|safe }}</p>
</body>
</html>