I have seen this related question but mine is a different topic.
I use a lot of inclusion in my templates. Basically one big template would process some of the page, then include smaller templates for reusable chunks. I also have widgets that renders their own templates.
The problem arises when I need to use Javascript. The big template needs a set of js files, while each of the small templates needs its own set of js files. The sets of js files can overlap, and each small template can be included more than once.
Now if I put the inclusion tag in each big template, I stand the risk of missing one or two js files. If I put the inclusion in the small templates, it may produce duplication. I'm not sur开发者_如何学Ce if the duplication is bad, but it doesn't look good.
Can somebody share the experience, what do you do to manage js files in Django?
for exactly this reason I wrote django-sekizai. It solves duplication as well as allowing you to put your js files at the bottom of the HTML no matter where in the template you are.
精彩评论