简体   繁体   中英

How can I apply base.html file for extending to every template in django

Is there a way to extend base.html file in python django by default, I want it because I am overwriting {% extends %} tag in every html file

No but what you can do however is created a new HTML file called for example, header-tags.html with something like that:

{% extends "base.html" %}
{% load static %}
.... more tags

And then include this snippet wherever you want with {% include 'header-tags.html' %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM