No exception in template using with and block.super
I am am using with tag to transfer flags to block.super like this: {% with something=1 %} {{ block.super }} {% endwith %} Now if block.super rises an exception, for example NoReverseMatch, instead of error page, the {{ block.super }} renders to an empty string, the exception is swallowed somewhere. This does not happen without the {% with %} wrapper. A bug? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Exception in template
Perfect, I want the empty string :) I was just asking myself if I was forcing some extra processing. Seems not. Thanks both of you. Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Exception in template
> {% for a in list %} > a.foo a.bar > {% endfor %} If you really need something to happen other than an empty string, you can always use the "if" tag: {% for a in list %} {% if a.foo %}{{ a.foo }}{% else %}Whatever exception text you want{% endif %} {{ a.bar }} {% endfor %} Erik -- portfolio: http://textivism.com/ blog: http://erikanderica.org/erik/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Exception in template
On Sat, 2008-04-12 at 22:13 -0300, Juanjo Conti wrote: > Suppose this template code: > > {% for a in list %} > a.foo a.bar > {% endfor %} > > The point is that only some elements of the "list" sequence have the > "foo" attribute, so a exception is thrown, but the template engine > silence it. > > Is may template code correct or some check should be done to avoid the > exception throw? It depends on what you want to happen. The template rendering is designed to behave as you are describing. It actually makes it easier to write reusable templates because you can access the "foo" attribute on something without worrying about whether it is present or not -- meaning the templates work for a broader range of objects. Any missing attributes are replaced with the empty string. So why is this a bad thing in your case and what do you want to have happen instead? Malcolm -- Atheism is a non-prophet organization. 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 -~--~~~~--~~--~--~---
Exception in template
Suppose this template code: {% for a in list %} a.foo a.bar {% endfor %} The point is that only some elements of the "list" sequence have the "foo" attribute, so a exception is thrown, but the template engine silence it. Is may template code correct or some check should be done to avoid the exception throw? Thanks and regards, Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Exception in template rendering
I was having the same problem with {{ object_list.count }}, but from the first link above found that {{ object_list|length }} does the trick. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [EMAIL PROTECTED] 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 -~--~~~~--~~--~--~---
Re: Exception in template rendering
Cesco, I just ran into this myself and it appears there is a ticket (two actually, one was closed as 'worksforme') for the bug: http://code.djangoproject.com/ticket/2351 http://code.djangoproject.com/ticket/2945 (closed) The 2-line patch attached to #2351 fixes the problem. Regards, Jeff On Mar 2, 5:19 pm, "checco" <[EMAIL PROTECTED]> wrote: > Hi, > > I was playing with the django application djangosnippets (the released > source code ofwww.djangosnippets.org) and I got the following error: > > "Caught an exception while rendering: no such column:count" > (it refers to the following snippet of code taken from thetemplate > snippets_list.html): > > {% block sidebar %} > {{ object_list.count}} snippet{{object_list.count|pluralize }} > posted so far. > {% endblock %} > > I don't know if that would cause the error but, please, note that the > object_list is not empty. Does anyone know why the error? I'm quite > new to django so any help will be highly appreciated. > > Thanks and regards > Cesco --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Exception in template rendering
Hi, I was playing with the django application djangosnippets (the released source code of www.djangosnippets.org) and I got the following error: "Caught an exception while rendering: no such column: count" (it refers to the following snippet of code taken from the template snippets_list.html): {% block sidebar %} {{ object_list.count }} snippet{{object_list.count|pluralize }} posted so far. {% endblock %} I don't know if that would cause the error but, please, note that the object_list is not empty. Does anyone know why the error? I'm quite new to django so any help will be highly appreciated. Thanks and regards Cesco --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---