{"id":7133,"date":"2013-01-28T06:55:54","date_gmt":"2013-01-28T06:55:54","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=7133"},"modified":"2024-04-12T14:17:09","modified_gmt":"2024-04-12T08:47:09","slug":"template-system-basics","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/","title":{"rendered":"Template system basics"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified-Django Developer\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Django Developer<br \/>\n<\/span><\/a><\/p>\n<h3 id=\"cn6\">Template System Basics<\/h3>\n<p id=\"cn7\">A Django template is a string of text that is intended to separate the presentation of a document from its data. A template defines placeholders and various bits of basic logic (i.e., template tags) that regulate how the document should be displayed. Usually, templates are used for producing HTML, but Django templates are equally capable of generating any text-based format.<\/p>\n<p id=\"cn8\">Let\u2019s dive in with a simple example template. This template describes an HTML page that thanks a person for placing an order with a company. Think of it as a form letter:<\/p>\n<pre id=\"cn9\">&lt;html&gt;\n&lt;head&gt;&lt;title&gt;Ordering notice&lt;\/title&gt;&lt;\/head&gt;\n\n&lt;body&gt;\n\n&lt;p&gt;Dear {{ person_name }},&lt;\/p&gt;\n\n&lt;p&gt;Thanks for placing an order from {{ company }}. It's scheduled to\nship on {{ ship_date|date:\"F j, Y\" }}.&lt;\/p&gt;\n\n&lt;p&gt;Here are the items you've ordered:&lt;\/p&gt;\n\n&lt;ul&gt;\n{% for item in item_list %}\n&lt;li&gt;{{ item }}&lt;\/li&gt;\n{% endfor %}\n&lt;\/ul&gt;\n\n{% if ordered_warranty %}\n&lt;p&gt;Your warranty information will be included in the packaging.&lt;\/p&gt;\n{% endif %}\n\n&lt;p&gt;Sincerely,&lt;br \/&gt;{{ company }}&lt;\/p&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p id=\"cn10\">This template is basic HTML with some variables and template tags thrown in. Let\u2019s step through it:<\/p>\n<ul>\n<li id=\"cn11\">\n<p id=\"cn12\">Any text surrounded by a pair of braces (e.g.,&nbsp;<tt>{{&nbsp;person_name&nbsp;}}<\/tt>) is a&nbsp;<em>variable<\/em>. This means \u201cinsert the value of the variable with the given name.\u201d How do we specify the values of the variables? We\u2019ll get to that in a moment.<\/p>\n<\/li>\n<li id=\"cn13\">\n<p id=\"cn14\">Any text that\u2019s surrounded by curly braces and percent signs (e.g.,&nbsp;<tt>{%&nbsp;if&nbsp;ordered_warranty&nbsp;%}<\/tt>) is a&nbsp;<em>template tag<\/em>. The definition of a tag is quite broad: a tag just tells the template system to \u201cdo something.\u201d<\/p>\n<p id=\"cn15\">This example template contains two tags: the&nbsp;<tt>{%&nbsp;for&nbsp;item&nbsp;in&nbsp;item_list&nbsp;%}<\/tt>&nbsp;tag (a&nbsp;<tt>for<\/tt>&nbsp;tag) and the&nbsp;<tt>{%&nbsp;if&nbsp;ordered_warranty&nbsp;%}<\/tt>&nbsp;tag (an&nbsp;<tt>if<\/tt>&nbsp;tag).<\/p>\n<p id=\"cn16\">A&nbsp;<tt>for<\/tt>&nbsp;tag acts as a simple loop construct, letting you loop over each item in a sequence. An&nbsp;<tt>if<\/tt>&nbsp;tag, as you may expect, acts as a logical \u201cif\u201d statement. In this particular case, the tag checks whether the value of the&nbsp;<tt>ordered_warranty<\/tt>&nbsp;variable evaluates to&nbsp;<tt>True<\/tt>. If it does, the template system will display everything between the&nbsp;<tt>{%&nbsp;if&nbsp;ordered_warranty&nbsp;%}<\/tt>&nbsp;and&nbsp;<tt>{%&nbsp;endif&nbsp;%}<\/tt>. If not, the template system won\u2019t display it. The template system also supports&nbsp;<tt>{%&nbsp;else%}<\/tt>&nbsp;and other various logic statements.<\/p>\n<\/li>\n<li id=\"cn17\">\n<p id=\"cn18\">Finally, the second paragraph of this template has an example of a&nbsp;<em>filter<\/em>, with which you can alter the display of a variable. In this example,&nbsp;<tt>{{ship_date|date:\"F&nbsp;j,&nbsp;Y\"&nbsp;}}<\/tt>, we\u2019re passing the&nbsp;<tt>ship_date<\/tt>&nbsp;variable to the&nbsp;<tt>date<\/tt>&nbsp;filter, giving the&nbsp;<tt>date<\/tt>&nbsp;filter the argument&nbsp;<tt>\"F&nbsp;j,&nbsp;Y\"<\/tt>. The&nbsp;<tt>date<\/tt>&nbsp;filter formats dates in a given format, as specified by that argument. Filters are attached using a pipe character (<tt>|<\/tt>), as a reference to Unix pipes.<\/p>\n<\/li>\n<\/ul>\n<div class=\"apply\">\n<h3>Apply for Django Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Django-Developer\">http:\/\/www.vskills.in\/certification\/Certified-Django-Developer<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Django Developer Template System Basics A Django template is a string of text that is intended to separate the presentation of a document from its data. A template defines placeholders and various bits of basic logic (i.e., template tags) that regulate how the document should be displayed. Usually,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[283],"tags":[6793,6792,2590,2603],"class_list":["post-7133","page","type-page","status-publish","hentry","category-django","tag-django","tag-django-developer","tag-django-developer-certification","tag-template-system-basics"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Template system basics - Tutorial<\/title>\n<meta name=\"description\" content=\"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Template system basics - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:47:09+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/\",\"name\":\"Template system basics - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-01-28T06:55:54+00:00\",\"dateModified\":\"2024-04-12T08:47:09+00:00\",\"description\":\"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Template system basics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Template system basics - Tutorial","description":"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/","og_locale":"en_US","og_type":"article","og_title":"Template system basics - Tutorial","og_description":"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:47:09+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/","name":"Template system basics - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-01-28T06:55:54+00:00","dateModified":"2024-04-12T08:47:09+00:00","description":"Template system basics. Govt of India Certification for Django developer. Get Certified and improve employability. Certification assesses candidates in Django concepts.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/template-system-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Template system basics"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=7133"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7133\/revisions"}],"predecessor-version":[{"id":121611,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7133\/revisions\/121611"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=7133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=7133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=7133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}