Hey Andrea,

Please have a look at
http://stackoverflow.com/questions/4300442/show-undefined-variable-errors-in-templates

Put this in your debug settings:

class InvalidString(str):
    def __mod__(self, other):
        from django.template.base import TemplateSyntaxError
        raise TemplateSyntaxError(
            "Undefined variable or unknown value for: \"%s\"" % other)

TEMPLATE_STRING_IF_INVALID = InvalidString("%s")

This should raise an error when the template engine sees or finds an
undefined value.

Another trick is to set TEMPLATE_STRING_IF_INVALID to "%s %s" and that
will cause a formatting error to be raised.

https://docs.djangoproject.com/en/1.2/ref/templates/api/#how-invalid-variables-are-handled

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 4:02 PM, andrea crotti
<andrea.crott...@gmail.com> wrote:
> I have a case where we use django templates, but it really makes no sense to
> render the templates if a value is not passed in the contentx, and it should
> just fail..
>
> I don't find anywhere how to force that though, I understand the default of
> failing silently but there should be a way also to fail making some noise,
> right?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to