Home » 
        Django
    
    
    Django | Creating and Using MasterPages
    
    
    
    
        
        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
     
    
     
    
     
    
     
    
    Step 2: Select Project Folder i.e. myapp (Outer One) and add new folder with name "templates".
     
    
     
            
    Step 3: This templates folder is root location for all html templates. Add a base template i.e. base.html in this folder.
     
            
    Step 4: I divided Base template (Master page) into 4 Sections i.e.
     
            
    
    Different Sections of Body Tag on base.html
     
            
     
            
     
            
     
            
    Step 5: Add Child Pages which are inherited from base.html and add their individual contents.
     
            
     
            
     
            
     
            
     
            
     
            
     
            
    Step 6: Add templates location to setting.py in admin app i.e. myapp (inner one)
     
            
     
            
    Step 7: Add Controller (i.e. views.py) in Admin App (i.e. myapp[inner one])
     
            
    Step 8: Add Controller Action Methods in Controller (i.e. views.py)
     
            
    Step 9: Map routes to action methods in urls.py of admin app (i.e. myapp[inner])
     
            
     
            
    Step 10: Run the Server 
     
            
     
            
    Step 11: Open browser and type: http://127.0.0.1:4500
     
            
    
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement