I need to extend the base template for a page in my Django application, but there are a few HTML elements that I need to exclude from this new page that is in the base. What is the best way to remove them? Do I just delete the elements with JQuery?
Share
You can use template blocks to achieve this. For example, in base.html, surround the HTML elements in a named block:
The HTML in the block will be used only if no other template overrides it. You can override it in your sub-template like this:
Now the value from sub-template will be used and will override the default value from base.html.