An error occurred while rendering the included file in Django / GAE

Typically, an error message is displayed in the browser if an error occurs while processing the Django / GAE template. But as soon as such an error is contained in the included file, not a single message is displayed - the "include" tag creates simply empty output, which makes development difficult.

Is there a way to show all errors?

+4
source share
1 answer

Write unit test in tests.py where you create the template using django.templates.Template . Check to see if anything else is displayed than None or "" or a space.

Once this unit test succeeds, you can move on to the following:

Use self.client to render the template using the full stack. If the problem is here, and not in the previous unit test, maybe something is wrong with your view function.

If you don't include your test code in try-catch, you get a full stack trace when something goes wrong. If there is no stack trace, but your test fails, you know you did something wrong.

In my opinion, unit tests in Django are real time keepers.

0
source

All Articles