On Fri, 2008-04-18 at 11:49 -0700, Salim Fadhley wrote:
> yml,
> 
> If I want to disable this behavior, is it possible? When a template
> tries to reference an invalid object (e.g. a context variable which
> has not been defined) I'd like to throw an exception. I do not want to
> invent a value.

No, you can't. The current behaviour is a design feature of the
templates, which help make writing templates that handle polymorphic
objects a lot easier.

Note that no value is "invented" when you access an attribute that
doesn't exist. Instead, None is returned. It's very consistent and
displays quite well (as nothing).

In the past, we have suggested that people could write a middleware to
look for the TEMPLATE_STRING_IF_INVALID string in the output. However,
you have to be a little careful there, since things like the admin
interface take advantage of the template behaviour, so you will break
your admin display if you use TEMPLATE_STRING_IF_INVALID (that setting
is really only for testing -- so adjusting your test suite to check for
it, as suggested elsewhere in this thread, is also a good plan).

Regards,
Malcolm

-- 
Depression is merely anger without enthusiasm. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to