Home » Django

Django | Creating and Using Templates

Creating and Using Templates in Django: Here, we are going to learn how to create and use templates in Django Web Development Framework?
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

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.