Django Template and URL Configuration

There are 4 steps to setting up template and URL configuration

Step 1: Open the settings.py file in your project folder and update the template section highlighted in the screenshot

Screen Shot 2015-11-07 at 8.23.45 AM

Step 2: Go to your application root, create a folder named templates and then create a file called home.html

<your project folder>

——– <your app folder>

——–    ——— /templates/home.html

Step 3: Open the views.py file under your application and add the following

Screen Shot 2015-11-07 at 8.33.24 AM

Step 4: Open the urls.py file under your project folder, import the view from your project and add the url pattern to route any root or http://127.0.0.1:8000/ request to the home.html

Screen Shot 2015-11-07 at 8.37.39 AM

That’s all there is to it.  You should see the following when you browse to http://127.0.0.1:8000/

Screen Shot 2015-11-07 at 8.39.33 AM

Django Template and URL Configuration

Leave a Reply

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