开发者

Detecting unused Django template libraries

开发者 https://www.devze.com 2023-04-01 13:24 出处:网络
W开发者_开发知识库hile rendering a template is there a way to make Django log something when unused tag libraries are loaded?I guess you could fold in your own load method into the django template lan

W开发者_开发知识库hile rendering a template is there a way to make Django log something when unused tag libraries are loaded?


I guess you could fold in your own load method into the django template language and add in a logmethod using Django logging, just out of curiosity, is it the complexity of the template variety that a logger makes it more conveinient to keep the helicopter view?


Here is what I would do, although this may not be the best solution.

  1. Write a script that goes through all of your urls.py files and builds up a tree of all the urls that exist in your project (I know there is a third-party django plugin to list all urls, but I cant seem to remember what it is)

  2. Build a unittest that takes the list generated in (1), using the Client() to hit every url, and then query the response objects for the templates which were rendered.

  3. Perform a logical AND with the list of total HTML files in your template directory and the list generated from this unit test.

0

精彩评论

暂无评论...
验证码 换一张
取 消