Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3421496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:06:39+00:00 2026-05-18T06:06:39+00:00

I am building my first Django website, after using Symfony 1.3.x to build a

  • 0

I am building my first Django website, after using Symfony 1.3.x to build a few website. Both frameworks employ the MVC pattern.

Symfony allows a ‘master’ template to be created (called the layout), and each individual view is then used to decorate the master layout, using the decorator pattern. This makes it very easy to design pages that use the same layour (e.g. header/footer etc), whilst differing on the actual page content.

I am looking to see if something similar is available in Django. So far, all of the examples I have seen involve creating seperate views. Doing things this way is not very DRY, as each of my view template is repeating a lot of common stuff (header/footer etc).

Is there a way to have a ‘master’ view (using Django terminology), that establishes the layout of the views that are applied to it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:06:40+00:00Added an answer on May 18, 2026 at 6:06 am

    From what you say I think that you used “view” instead of “template”. If you meant “template”, you should know that django has a solution to this problem: template inheritance. Basically, you should design a “base” template that would be the skeleton of every page, and ther particular templates would inherit that template. Here is a short example taken from the django docs:

    {% extends "base_generic.html" %}
    
    {% block title %}{{ section.title }}{% endblock %}
    
    {% block content %}
    <h1>{{ section.title }}</h1>
    
    {% for story in story_list %}
    <h2>
      <a href="{{ story.get_absolute_url }}">
        {{ story.headline|upper }}
      </a>
    </h2>
    <p>{{ story.tease|truncatewords:"100" }}</p>
    {% endfor %}
    {% endblock %}
    

    The docs don’t have an example for base_generic.html, but a simple one would look like this:

    <html>
        <head>
            <title>{% block title %} Default title {% endblock %}</title>
            <!-- other stuff -->
        </head>
        <body>
            <!-- header, etc -->
            {% block content %}
            Default content
            {% endblock %}
            <!-- footer -->
        </body>
    </html>
    

    Note that Default title from base_generic.html will be replaced by {{ section.title }} from the template that extends it. If there was no title block in the template that extends base_generic.html, the title would have been Default title. This happens for all blocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building my first website with rails,it consists of a blog, a few static
I'm building my first ASP.NET MVC website, and I'm trying to figure out how
I'm building my first personal website using Zend 1.11. To create the directory structure
I'm building a fairly large website in Django, and it's my first time doing
I am building my first django app that uses user authentication and I'm using
I'm building my first ASP.NET MVC application and I am having some troubles with
So I'm building my first ever website with user accounts. What data should I
My team is building our first significant Silverlight application, using a 3 layered architecture
I'm building my first MVC3 website and have connected my site to a mdf
I'm building my first CodeIgniter app - and have a registration form. I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.