I've used a solution like the one Emil links to before to great success,
though perhaps there's scope to make it a bit less hacky in Django.

On 22 September 2017 at 07:10, Emil Stenström <e...@kth.se> wrote:

> It as actually possible, just in a very hacky way. Django has a setting
> called TEMPLATE_STRING_IF_INVALID (or TEMPLATES[0]["OPTIONS"]["strin
> g_if_invalid"] in current versions of Django). If you override it and set
> it to a class with a __str__ that raises an exception you can get the
> effect you want. We use this in tests to find missing variables quickly.
>
> Reference code: https://djangosnippets.org/snippets/646/
>
> On Thursday, 21 September 2017 13:05:28 UTC+2, Shreyas Pandya wrote:
>>
>> Hi All,
>>
>> What is your opinion on having an option to raise an error in template if
>> variable is not found in context. This may be useful for automated  tests
>> as discussed in ticket.
>>
>> reference ticket #28618 <https://code.djangoproject.com/ticket/28618> ;
>>
>> Thanks
>>
>> regards
>> Shreyas
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/02995ca2-2721-4526-89de-
> 408bb3be642d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/02995ca2-2721-4526-89de-408bb3be642d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM2RDaGtMzu%2B93nuFP0DS6%2BFa1ZM8PQeaavoa%3D%2BASKGaVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to