...

/

Code Templates in Django

Code Templates in Django

Let’s learn about all the steps of writing templates with code.

Example of a template

For this example, we will use the example from the Variables lesson. We already know some of these steps, but we will go through them once again to help reinforce the concepts.

We need to perform the following steps:

Step 1: Create a templates directory

First, we will create a templates directory in the outermost first_project directory. Then, inside the templates directory, we will add another directory by the name of our application, called first_app, such that the hierarchy becomesfirst_project/templates/first_app/.

Step 2: Tell Django where to find templates

As we saw in the previous lesson, we have to use ...