12👍
Have a look at Django Template Coverage tool: https://github.com/traff/dtcov
It does exactly what you need.
EDIT: Django Template Coverage was merged to coverage.py as a plugin:
http://nedbatchelder.com/blog/201501/coveragepy_for_django_templates.html
It is recommended to use it instead of original project.
1👍
Templates do not store any kind of line number information like python source code does. The best you could do is monkey patch the NodeList object to record how many times each node has been evaluated, and then re-render the templates in a special mode that will show which nodes are evaluated.
EDIT: I have been corrected.
Templates DO store line number information, but only for the start of a token. I.E. if you have a TextNode span multiple lines, you will need to handle that yourself. There is some interesting code in django.templates.debug that may be useful for constructing such a coverage reporter.
- [Django]-How does pgBouncer help to speed up Django
- [Django]-Get name of primary field of Django model
- [Django]-Sort order of Django Admin records
0👍
I don’t think you can get coverage info from templates, but you can find out which templates are rendered by connecting the template_rendered signal. Your receiver would store the names of the rendered templates.
Then, you could easily find out which templates are not rendered with the find command.
- [Django]-Raw query must include the primary key
- [Django]-Return the current user with Django Rest Framework
- [Django]-React Proxy error: Could not proxy request /api/ from localhost:3000 to http://localhost:8000 (ECONNREFUSED)