Home » Django

Django | Creating and Using MasterPages

In this tutorial, we are going to learn how to create and use MasterPages in Django Web Development Framework?
Submitted by Pankaj Singh, on October 26, 2018

Creating and Using MasterPages in Django

MasterPages are a type Template that are used to implement common design across the web applications.

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

creating and using masterpages 1

creating and using masterpages 2

creating and using masterpages 3

creating and using masterpages 4

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

creating and using masterpages 5

creating and using masterpages 6


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

creating and using masterpages 7

Step 4: I divided Base template (Master page) into 4 Sections i.e.

creating and using masterpages 8

Different Sections of Body Tag on base.html

creating and using masterpages 9

creating and using masterpages 10

creating and using masterpages 11

creating and using masterpages 12


Step 5: Add Child Pages which are inherited from base.html and add their individual contents.

creating and using masterpages 13

creating and using masterpages 14

creating and using masterpages 15

creating and using masterpages 16

creating and using masterpages 17

creating and using masterpages 18

creating and using masterpages 19

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

creating and using masterpages 20

creating and using masterpages 21


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

creating and using masterpages 22

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

creating and using masterpages 23

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

creating and using masterpages 24

creating and using masterpages 25


Step 10: Run the Server

creating and using masterpages 26

creating and using masterpages 27

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

creating and using masterpages 28






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.