Introduction to HTML and creating your First Template(Part IX)

In this tutorial, we are going to learn what is HTML, its features, uses and how to use it to create our first Django template to be showcased on our blog web application.

This tutorial is a part of our series onĀ Creating Blog Website using Django.

Link to the Previous tutorial:

Introduction to Django Views and how to create them(Part VIII)

What is HTML?

HTML also know as Hypertext Mark-Up Language; is a coding language which is interpreted by the web browsers like Google Chrome, Safari, etc.

HTML can be used to display any type of data varying from simple plain text to High Definition graphics.

Further, HTML consists of tags starting from < and ending with > which basically tells about the different types of embedded elements on the web page.

Create a Template in Django

To create a Template, create a post.html file in your blog1/template/blog1 directory. Open it in your Code editor and input the following code in it:

<html>
    <head>
        <title>First blog</title>
    </head>
    <body>
        <p>Hello World !</p>
        <p>Learning Django</p>
    </body>
</html>

Now, run the following code :

python manage.py runserver

 

Open your browser at the default address; and Ta-Da the error is no longer there.

create template in django

Further, you will see the text you have entered to be visible on your Web page. You can try this out with your Elements.

Here, is a list of some tags you can use to further enhance your web page.

To add the main heading :

<h1>Heading</h1>

for Sub-Headings, just replace h1 with h2 and so on.

To make the text bold :

<strong>highlighted_text</strong>

Insert a link :

<a href="http://170.187.134.184">link</a>

To create a Paragraph :

<p>Paragraph</p>

That’s it! Try creating your own templates using the tags mentioned above.

Further, feel free to ask any doubts in the comment section below.

Also, have a look at other posts :

One response to “Introduction to HTML and creating your First Template(Part IX)”

  1. Matt says:

    For anyone that is having problems with “Template Not Found” errors then change the name of the blog1/template directory to blog1/templates (the ‘s’ is necessary.

    Also the final argument (the empty tuple ‘()’) in the render argument should be a dictionary. I found passing an empty dictionary was fine. To do this change the ‘()’ to ‘{}’.

    Best,

    Matt

Leave a Reply

Your email address will not be published. Required fields are marked *