{"id":83897,"date":"2021-08-30T09:00:02","date_gmt":"2021-08-30T03:30:02","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=83897"},"modified":"2021-08-30T09:00:02","modified_gmt":"2021-08-30T03:30:02","slug":"django-templates-create-your-first-template-in-easy-steps","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/","title":{"rendered":"Django Templates: Create your First Template in easy steps"},"content":{"rendered":"<p>The third and most significant aspect of Django&#8217;s MVT Structure is templates. In Django, a template is a .html file that is prepared in HTML, CSS, and Javascript. The Django framework efficiently manages and generates dynamically generated HTML web pages for end-user viewing. Django is mostly a backend framework, thus we use templates to offer a frontend and a layout for our website.<\/p>\n<p>All static objects in a web page developed with Django hold the templates for generating the static entities, which are important to understand and run the process of Django applications. In other words, the templates are in charge of constructing the skeleton of a webpage. These templates allow you to set up an MVT-oriented architecture in Django. A Django view is used to render the templates used in a Python setup.<\/p>\n<h3>What are Django Templates?<\/h3>\n<p>Django templates combine a static HTML layout with Django Syntax, which is Python code. Both of these components aid in the dynamic generation of HTML pages, making your website more user-friendly. The basic goal of Django templates is to keep the data representation distinct from the data itself.<\/p>\n<h3>Need of Templates in Django<\/h3>\n<p>We can&#8217;t put python code in an HTML file since the code is only interpreted by the Python interpreter, not the browser. HTML is a static markup language, but Python is a dynamic programming language.<\/p>\n<p>The Django template engine separates the design from the python code, allowing us to create dynamic web pages.<\/p>\n<h3>Rendering Django Views using Templates.<\/h3>\n<h4>Step 1: Activate the virtual environment<\/h4>\n<p>Navigate to the location where the Virtual Environment setup was built.<\/p>\n<p>To activate your virtual environment, type the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">(virtual-environment-name)\\Scripts\\activate.bat<\/pre>\n<p>The virtual environment is active now.<\/p>\n<p>To get to your project folder, change the directory. Here it is &#8220;TechVidvan2.&#8221;<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84845\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step1.png\" alt=\"Django template\" width=\"1120\" height=\"550\" \/><\/a><\/p>\n<h4>Step 2: Create an application.<\/h4>\n<p>We will be working with the same application \u201cEmployee\u201d that we used in the previous tutorial of Models and Views.<\/p>\n<h4>Step 3: Make a template folder under Root Project.<\/h4>\n<p>This folder could be used to store all template-related HTML code. Under the root project folder, a template folder should be created.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-3-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84846\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-3-2.png\" alt=\"Django Templates\" width=\"371\" height=\"483\" \/><\/a><\/p>\n<h4>Step 4: Tag the template folder in the settings.py file<\/h4>\n<p>The settings.py file is used to link these templates to the views they belong to. When the tagging procedure is complete, any HTML content included within the folder will fall under this template area.<\/p>\n<p><strong>Code for making changes in the settings.py file:<\/strong><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-4_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84847\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-4_1.png\" alt=\"Django Template folder\" width=\"1016\" height=\"384\" \/><\/a><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-4_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84848\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-4_2.png\" alt=\"Django Template folder\" width=\"1040\" height=\"381\" \/><\/a><\/p>\n<p>The python path in the BACKEND key is used to implement the Django template&#8217;s API backend.<br \/>\n<strong>django.template.backends.django.DjangoTemplates<\/strong> and <strong>django.template.backends.jinja2.Jinja2<\/strong> are two examples of Django built-in backends.<\/p>\n<ul>\n<li>The DIRS directory contains the directory where the template engine needs to look for template-related search files.<\/li>\n<li>On the other hand, APP DIRS is useful for indicating the location where the engine must verify the templates within the installed applications. Each defined backend assigns a standard name to each subdirectory within the apps.<\/li>\n<\/ul>\n<h4>Step 5: Put the HTML file in the templates directory<\/h4>\n<p>Now we will work with the newly created Employee_details.html file. This is the file where the actual design of the web application happens. We can do much stuff in here, from changing the background colour to inserting some of the images.<\/p>\n<p>Being this is our initial module, we will do some basic tasks here.<\/p>\n<p><strong>Code for the newly created Employee_details.html file:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;style&gt;\n        body{\n            background-color:burlywood;\n        }\n    &lt;\/style&gt;\n    &lt;title&gt;Employee_details&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;The Employees Here at TechVidvan&lt;\/h1&gt;\nEmployee name: {{ first_name }}\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<h4>Step 6: Making changes in the views.py file<\/h4>\n<p>To load the template, call the Employee_Details() method and pass the .html file that we just created.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.shortcuts import render\nfrom django.http import HttpResponse\n\n# Create your views here.\n \ndef Employee_Info(request):\n    return HttpResponse('&lt;h1&gt;Welcome to TechVidvan Employee Portal&lt;\/h1&gt;')\n \ndef Employee_Details(request):\n    return render (request,'Employee_details.html')\n<\/pre>\n<h4>Step 7: Modifying the urls.py file<\/h4>\n<p>Set a URL to use in the browser to access the template.<\/p>\n<p>Initially make changes to the urls.py file under the application (Employee).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.urls import path\nfrom Employee import views\n\nurlpatterns = [\n    path('TechVidvan2\/', views.Employee_Info),\n    path('TechVidvan\/', views.Employee_Details),\n] \n<\/pre>\n<p>Then make some changes to the urls.py file under the root project directory.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.contrib import admin\nfrom django.urls import path\nfrom Employee import views\n\nurlpatterns = [\n    path('admin\/', admin.site.urls),\n    path('TechVidvan2\/', views.Employee_Info),\n    path('TechVidvan\/', views.Employee_Details),\n]<\/pre>\n<h4>Step 8: Start the server.<\/h4>\n<p>Run the following command and go to <strong>localhost:8000\/TechVidvan<\/strong> in your browser to see the template.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">python manage.py runsever\n<\/pre>\n<p>You will see the following output on the browser.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84849\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Step-8.png\" alt=\"Django server\" width=\"1920\" height=\"1028\" \/><\/a><\/p>\n<p>That&#8217;s it, you&#8217;ve just finished making your first Django Template.<\/p>\n<h3>Django template language<\/h3>\n<p>Django Templates provides this as one of its most important features. A Django template is a text file or a Python string that has been marked up with the Django template language. The template engine understands and recognises certain constructs. Variables and tags are the most common.<\/p>\n<p>There are four major constructs in the Django template language&#8217;s syntax.<\/p>\n<h4>1. Variables in Django<\/h4>\n<p>Variables return a value from the context, a dict-like object that maps keys to values. The context object sent by the view can be accessed in the template using Django Template variables.<\/p>\n<p><strong>Syntax of variable:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{{ variable_name }}<\/pre>\n<p><strong>Example of Using a variable in the code:<\/strong><\/p>\n<p>Now create a view through which we will pass the context dictionary, in Employees\/views.py,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.shortcuts import render\n\n\ndef Employee_Details(request):\n  # create a dictionary\n  context = {\n    \"first_name\" : \"Raghav\",\n  }\n  return render(request, \"Employee_details.html\", context)\n<\/pre>\n<p>Create a url path to map to this view, in Employees\/urls.py,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.urls import path\n\n# importing views from views..py\nfrom .views import Employee_Details\n\nurlpatterns = [\n  path('', Employee_Details),\n]<\/pre>\n<p>Make changes in Employee_details.html<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Employee name: {{ first_name }}.<\/pre>\n<p>This brings the following Output:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Variable.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84850\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/Variable.png\" alt=\"Django variable\" width=\"1920\" height=\"1024\" \/><\/a><\/p>\n<h4>2. Tag in Django<\/h4>\n<p>Tags allow arbitrary logic in the rendering process in a template.<\/p>\n<p><strong>Syntax of Tag:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% tag_name %}<\/pre>\n<p><strong>Using Tag in the code:<\/strong><\/p>\n<p>Tags are surrounded by {% and %} like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% csrf_token %}<\/pre>\n<p>In templates, there are numerous tags that are used. Here are a few examples:<\/p>\n<ul>\n<li>\n<h5>Using if\/else:<\/h5>\n<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% if condition %} \n  renders if body \n{% else %} \n    renders else body \n{% endif %}\n<\/pre>\n<ul>\n<li>\n<h5>By Using For loop:<\/h5>\n<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% for odd in odds %}\n{{odd}}\n{% endfor %}<\/pre>\n<ul>\n<li>\n<h5>Putting Include in the code:<\/h5>\n<\/li>\n<\/ul>\n<p>This is used to load and render a template in the current context. It&#8217;s great for developing multiple components, such as navbars, footers, and so on, and then combining them into multiple templates.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% include template_name %}\n<\/pre>\n<ul>\n<li><strong>Making the use of block:<\/strong><br \/>\nThis is the block that the child template will override. When we talk about template inheritance, you&#8217;ll get a better understanding of blocks.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% block content %}\n{% endblock %}\n<\/pre>\n<h4>List of Commonly Used Tags<\/h4>\n<table style=\"height: 234px\" width=\"920\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Comment<\/span><\/td>\n<td><span style=\"font-weight: 400\">cycle<\/span><\/td>\n<td><span style=\"font-weight: 400\">extends<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">if<\/span><\/td>\n<td><span style=\"font-weight: 400\">For loop<\/span><\/td>\n<td><span style=\"font-weight: 400\">For&#8230;empty loop<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Boolean Operators<\/span><\/td>\n<td><span style=\"font-weight: 400\">firstof<\/span><\/td>\n<td><span style=\"font-weight: 400\">Include\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">lorem<\/span><\/td>\n<td><span style=\"font-weight: 400\">now<\/span><\/td>\n<td><span style=\"font-weight: 400\">url<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3. Filters \/ {{ metadata | response }} in Django<\/h4>\n<p>As Django is a web framework, it will also provide content based on metadata, which is where the filters come in handy.<\/p>\n<p>These filters are particularly useful when working on a large project where the site&#8217;s metadata is vital; otherwise, they aren&#8217;t as useful for smaller blog websites.<\/p>\n<p>The variable&#8217;s and tag argument&#8217;s values are transformed using the filter.<\/p>\n<p><strong>Syntax of using Django Filters:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{{ variable_name | filter_name }}\n<\/pre>\n<p><strong>Example of using Filters:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{{ my_date|date:\"d-m-y\" }}<\/pre>\n<h4>Major Template Filters in Django<\/h4>\n<table style=\"height: 314px\" width=\"868\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">add<\/span><\/td>\n<td><span style=\"font-weight: 400\">addslashes<\/span><\/td>\n<td><span style=\"font-weight: 400\">capfirst<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">center<\/span><\/td>\n<td><span style=\"font-weight: 400\">Cut\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">date<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">default<\/span><\/td>\n<td><span style=\"font-weight: 400\">dictsort<\/span><\/td>\n<td><span style=\"font-weight: 400\">divisibleby<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">escape<\/span><\/td>\n<td><span style=\"font-weight: 400\">filesizeformat<\/span><\/td>\n<td><span style=\"font-weight: 400\">first<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Join\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">last<\/span><\/td>\n<td><span style=\"font-weight: 400\">length<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. Comments in Django<\/h4>\n<p>Comments are one of the most effective ways to improve code reusability and readability. As a result, the Django framework includes a special tag for commenting in the template language.<\/p>\n<p><strong>The general syntax of Comments is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{# this will not be rendered by the browser #}\n<\/pre>\n<p><strong>Example of using comments:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{# Comment here. It won't be rendered #}<\/pre>\n<p>Django Templates are made up of four core structures. To improve the appearance of our website, we will implement the same in many methods.<\/p>\n<h3>Django Template inheritance<\/h3>\n<p>The most powerful and, as a result, most complex aspect of Django&#8217;s template engine is template inheritance. You can create a &#8220;skeleton&#8221; template that contains all of your site&#8217;s common elements and defines blocks that child templates can override. In Django, the extends tag is used to inherit templates.<\/p>\n<p><strong>Syntax of Template Inheritance:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% extends 'template_name.html' %}<\/pre>\n<p>Let&#8217;s have a look at template inheritance with an example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n    &lt;title&gt;{% block title %}Employee Portal{% endblock %}&lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;div id=\"sidebar\"&gt;\n        {% block sidebar %}\n        &lt;ul&gt;\n            &lt;li&gt;&lt;a href=\"\/\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\n            &lt;li&gt;&lt;a href=\"\/About\/\"&gt;About&lt;\/a&gt;&lt;\/li&gt;\n        &lt;\/ul&gt;\n        {% endblock %}\n    &lt;\/div&gt;\n\n    &lt;div id=\"content\"&gt;\n        {% block content %}{% endblock %}\n    &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>This template, called base.html, creates an HTML skeleton document that you can use to create a two-column page. The &#8220;child&#8221; templates&#8217; responsibility is to fill up the empty blocks with content.<br \/>\nThe block tag in this example defines three blocks that child templates can fill up. The block tag simply informs the template engine that those elements of the template may be overridden by a child template.<\/p>\n<p><strong>The following is an example of a child template:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{% extends \"base.html\" %}\n\n{% block title %}Welcome to the About Page{% endblock %}\n\n{% block content %}\n{% for entry in Employee_Info%}\n    &lt;h2&gt;{{ entry.title }}&lt;\/h2&gt;\n    &lt;p&gt;{{ entry.body }}&lt;\/p&gt;\n{% endfor %}\n{% endblock %}\n<\/pre>\n<p>The extends tag is crucial in this case. It informs the template engine that this template &#8220;extends&#8221; another template. The template system locates the parent \u2013 in this case, &#8220;base.html&#8221; \u2013 before evaluating the template.<\/p>\n<p>When the template engine notices the three-block tags in base.html, it will replace them with the contents of the child template.<\/p>\n<p>The result could look like this, depending on the value of Employee_Info:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n    &lt;title&gt;Welcome to the About Page&lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;div id=\"sidebar\"&gt;\n        &lt;ul&gt;\n            &lt;li&gt;&lt;a href=\"\/\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\n            &lt;li&gt;&lt;a href=\"\/About\/\"&gt;About&lt;\/a&gt;&lt;\/li&gt;\n        &lt;\/ul&gt;\n    &lt;\/div&gt;\n\n    &lt;div id=\"content\"&gt;\n        &lt;h2&gt;Entry one&lt;\/h2&gt;\n        &lt;p&gt;This is my first entry.&lt;\/p&gt;\n\n        &lt;h2&gt;Entry two&lt;\/h2&gt;\n        &lt;p&gt;This is my second entry.&lt;\/p&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>Since this sidebar block was not defined by the child template, the value from the parent template was used instead. Content within a parent template&#8217;s {% block %} tag is always utilised as a fallback.<br \/>\nYou can use as many inheritance levels as you want. The following three-level approach is a standard way to use inheritance:<\/p>\n<ul>\n<li>Make a base.html template that contains your site&#8217;s overall appearance and feel.<\/li>\n<li>Each \u201csection\u201d of your site should have its base_SECTIONNAME.html template. base_news.html and base_sports.html are two examples. All of these templates are built on top of base.html and include section-specific styling and design.<\/li>\n<li>Create unique templates for each page type, such as a news item or a blog post.<br \/>\nThis method maximises code reuse and aids in the addition of things to shared content sections like section-wide navigation.<\/li>\n<\/ul>\n<h3>Summary<\/h3>\n<p>We covered the three most important aspects of web programming, along with Django.<\/p>\n<ul>\n<li>Models, as we learnt, are used to transmit data between the database and the view, and they hold the data definition for our website.<\/li>\n<li>Views serve as a link between models and templates, as well as a gateway for server data. They are where the business logic is kept.<\/li>\n<li>Django uses templates extensively, and they are currently the greatest implementation of loosely coupled architectures.<\/li>\n<\/ul>\n<p>A Django template is a basic building piece of a dynamic Django application that deals with delivering information from a Django view to the browser.<\/p>\n<p>If you have any queries, please leave them in the comments section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The third and most significant aspect of Django&#8217;s MVT Structure is templates. In Django, a template is a .html file that is prepared in HTML, CSS, and Javascript. The Django framework efficiently manages and&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84844,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3383],"tags":[4131,4132,4133],"class_list":["post-83897","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django","tag-django-template-language","tag-django-templates","tag-django-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Django Templates: Create your First Template in easy steps - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about Django Templates and their need. See Rendering Django Views using Templates and Django template language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Django Templates: Create your First Template in easy steps - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about Django Templates and their need. See Rendering Django Views using Templates and Django template language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-30T03:30:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Django Templates: Create your First Template in easy steps - TechVidvan","description":"Learn about Django Templates and their need. See Rendering Django Views using Templates and Django template language.","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:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/","og_locale":"en_US","og_type":"article","og_title":"Django Templates: Create your First Template in easy steps - TechVidvan","og_description":"Learn about Django Templates and their need. See Rendering Django Views using Templates and Django template language.","og_url":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-08-30T03:30:02+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Django Templates: Create your First Template in easy steps","datePublished":"2021-08-30T03:30:02+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/"},"wordCount":1610,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg","keywords":["Django Template Language","Django Templates","Django variables"],"articleSection":["Django Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/","url":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/","name":"Django Templates: Create your First Template in easy steps - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg","datePublished":"2021-08-30T03:30:02+00:00","description":"Learn about Django Templates and their need. See Rendering Django Views using Templates and Django template language.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/07\/Django-Template.jpg","width":1200,"height":628,"caption":"Django Templates"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/django-templates-create-your-first-template-in-easy-steps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Django Templates: Create your First Template in easy steps"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/83897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=83897"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/83897\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84844"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=83897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=83897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=83897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}