Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Django - Template inheritance

Back


Template Inheritance


Example: Template Inheritance

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="style.css" />
    <title>__ block title __ My amazing site__ endblock __</title>
  </head>

  <body>
    <div id="sidebar">
      __ block sidebar __
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/blog/">Blog</a></li>
      </ul>
      __ endblock __
    </div>

    <div id="content">__ block content __ __ endblock __</div>
  </body>
</html>
__ extends "base.html" __ __ block title __My amazing blog__ endblock __ __
block content __ __ for entry in blog_entries __
<h2></h2>
<p></p>
__ endfor __ __ endblock __

TOP