How to throw exception if input params is invalid in Django Template

Solution 1:

In Django<=1.9

TEMPLATE_STRING_IF_INVALID = 'DEBUG WARNING: undefined template variable [%s] not found'

in your settings.py.

In Django>=1.10

string_if_invalid = 'DEBUG WARNING: undefined template variable [%s] not found'

Also check this link about invalid template variables

And this link about django backend template engine