Resolving template block conflicts with third-party django applications

When connecting a third-party django application, I usually want it to integrate aesthetically with the rest of my django project. Although this is usually associated with redefining base.html applications (if so), we all structure our templates a little differently, so incompatibilities often arise. For example, suppose an application defines {% block footer %}and uses it for different things in all of its templates. If I already use {% block footer %}for, say, a navigation bar or copyright information, I do not want application templates to overlap my block.

A simpler, connected case will use different block names for the same thing. For example, {% block extra-head %}compared to {% block extrahead %}.

What is the best way to resolve such situations? Ideally, it would be nice to redo the blocks so that you can do things like “put the child {% block footer %}in the parent {% block content-footer %}”. Is there any way to get closer to this? Or is it the only solution to simply override each conflicting pattern?

+3
source share
1 answer

First, html inheritance should go:

my-sitebase.html
 |-- app-base.html
   |-- app-foo-template.html

I think this is what you had in mind, but the wording was a bit ambiguous. Perhaps you can just edit the app-base.html file.

-, , - {% block footer%}, , , - -.

- {% block footer%}, app-base.html, .

, - . IDE, , Text-Crawler , , IDE.

, , djangoslingshot.com, - . , find-replace , , , , - .

+1

All Articles