Chapter Three Django Templates System
Chapter Three Django Templates System
Django Template
System
BY:Eng Mohamed Ahmed Mohamed
Introduction
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Function performed by
templates tags
Display Logic Loop Control Block Declaration
{% if %} {% for x in y {% block
... %} content %}
{% endif ... ...
%} {% endfor %} {% endblock %}
{% include {% extends
"header.html" "base.html"
%} %}
Filters
01 {{string|truncatewords:80}}
02 {{string|lower}}
{{string|escape|linebreaks}}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Basic Site Template</title>
</head>
<body>
<h1>{{ title }}</h1>
<p>{{ cal }}</p>
</body>
</html>
Thank You
•Question
•And
•Answers