Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django project base template

Can I create a base template for my project which all apps can draw from? Or do I have to create a base template for each app? And if I wanted them to be the same I'd just copy them?

like image 201
heri0n Avatar asked Feb 06 '13 02:02

heri0n


People also ask

What template does Django use?

The Django template language is Django's own template system. Until Django 1.8 it was the only built-in option available. It's a good template library even though it's fairly opinionated and sports a few idiosyncrasies.

What is DTL in Django?

Django Template Language (DTL) is the primary way to generate output from a Django application. You can include DTL tags inside any HTML webpage. The basic DTL tag you can include in an HTML webpage is: 1. {% Tag %}

What does {{ name }} this mean in Django templates?

What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.

What's the default base template for all templates?

{1930BBEB-7805-471A-A3BE-4858AC7CF696} is the default value and points to /sitecore/templates/System/Templates/Standard template . That's it!


1 Answers

Sure you can. A quick example of a base.html

<!DOCTYPE html> <html>     <head>         <title>My Project</title>     </head>      <body>     {% block content %}{% endblock content %}     </body> </html> 

And say you have a app called myapp with a view.html page,

{% extends "base.html" %}  {% block content %}     <h2>Content for My App</h2>     <p>Stuff etc etc.</p> {% endblock content %} 

Take some time to read the docs for more information

like image 112
Kenny Shen Avatar answered Sep 24 '22 22:09

Kenny Shen