开发者

No errors shown rendering an included file in Django/GAE

Usua开发者_StackOverflowlly an error message is shown in browser if any error occured processing a Django/GAE template. But once such error is contained in an included file, then none message is shown - the "include" tag produces just blank output making development difficult.

Is there a way to show all errors?


Write a unit test in tests.py, where you render the template using django.templates.Template. Check there whether it renders to something else than None or "" or white space.

Once that unit test succeeds, you can proceed with the next one:

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

If you don't enclose your code under test in try-catch, you get the 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-savers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜