Skip to content

Commit d49a2d0

Browse files
committed
Add jinja2 template to example app.
1 parent 8022782 commit d49a2d0

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

example/settings.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
STATIC_URL = "/static/"
4242

4343
TEMPLATES = [
44+
{
45+
"NAME": "jinja2",
46+
"BACKEND": "django.template.backends.jinja2.Jinja2",
47+
"APP_DIRS": True,
48+
"DIRS": [os.path.join(BASE_DIR, "example", "templates", "jinja2")],
49+
},
4450
{
4551
"BACKEND": "django.template.backends.django.DjangoTemplates",
4652
"APP_DIRS": True,
@@ -54,7 +60,7 @@
5460
"django.contrib.messages.context_processors.messages",
5561
],
5662
},
57-
}
63+
},
5864
]
5965

6066
USE_TZ = True

example/templates/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<h1>Index of Tests</h1>
1010
{% cache 10 index_cache %}
1111
<ul>
12+
<li><a href="/jinja/">Jinja2</a></li>
1213
<li><a href="/jquery/">jQuery 3.3.1</a></li>
1314
<li><a href="/mootools/">MooTools 1.6.0</a></li>
1415
<li><a href="/prototype/">Prototype 1.7.3.0</a></li>

example/templates/jinja2/index.jinja

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
5+
<title>jinja Test</title>
6+
</head>
7+
<body>
8+
<h1>jinja Test</h1>
9+
{% for i in range(10) %}{{ i }}{% endfor %} {# Jinja2 supports range(), Django templates do not #}
10+
</body>
11+
</html>

example/urls.py

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
urlpatterns = [
88
path("", TemplateView.as_view(template_name="index.html"), name="home"),
9+
path(
10+
"jinja/",
11+
TemplateView.as_view(template_name="index.jinja", template_engine="jinja2"),
12+
),
913
path("jquery/", TemplateView.as_view(template_name="jquery/index.html")),
1014
path("mootools/", TemplateView.as_view(template_name="mootools/index.html")),
1115
path("prototype/", TemplateView.as_view(template_name="prototype/index.html")),

0 commit comments

Comments
 (0)