What is the best practice for either testing or making sure that all your template variables are in fact existing.
Assume that we have the following template
<html>
<div>{{ existing_object.non_existing_attribute }}</div>
</html>
We have an existing object. So we can't really test the response context like in the following answer: Django Unitest Checking Value Of Template Variable
There is string_if_invalid
as described in the documentation. But that should only be used for debugging purposes.
Any insight on how to best avoid this would be helpful!
Edit: Let's assume that the non-existing attribute is a bug. Ie I misspelt the variable, because of this it's showing up as an empty string.
Edit2: This question has a lot better answers: https://stackoverflow.com/a/7854404/554903