×

Django Tutorial

Django Examples

Django Practice

Django | Creating and Using Templates

Submitted by Pankaj Singh, on October 23, 2018

Templates are html files that are used as user interfaces in Django.

Step 1: Create Sandbox, Activate it, Install Django 1.9, Create Sample Project

creating and using templates 1

creating and using templates 2

creating and using templates 3

creating and using templates 4

Step 2: Select Project Folder i.e. myapp (Outer One) and add new folder with name "templates".

creating and using templates 5

creating and using templates 6


Step 3: This templates folder is root location for all html templates. Add a template i.e. index.html in this folder.

creating and using templates 7

Step 4: Add some html code in index.html template.

creating and using templates 8

Step 5: Add templates location to setting.py in admin app i.e. myapp(inner one)

creating and using templates 9

creating and using templates 10


Step 6: Step 6: Add Controller (i.e. views.py) in Admin App (i.e. myapp[inner one])

creating and using templates 11

Step 7: Add Controller Action Methods in Controller (i.e. views.py)

creating and using templates 12

Step 8: Map routes to action methods in urls.py of admin app(i.e. myapp[inner])

creating and using templates 13

creating and using templates 14

Step 9: Run the Server

creating and using templates 15

Step 10: Open browser and type: http://127.0.0.1:4500

creating and using templates 16

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.