Thanks, that solves my problem.

On Mon, Sep 16, 2013 at 4:38 PM, C. Kirby <[email protected]> wrote:

> If you successfully get to render_to_response (or similar) the template
> renderer will silently swallow errors.
> If you want the error to stop rendering and either print an error or a 500
> or something similar, test it in the view before rendering.
>
> Assuming you have an entry (or list of entries I guess) in your view:
>
> for entry in entries: #for a list of entries
>    try:
>        entry.state
>     except:
>        return HttpResponse(status = 500)
>
> or something similar
>
>
>
> On Monday, September 16, 2013 5:36:02 AM UTC-5, Ladislav P wrote:
>>
>> I have some custom functions in model classes which processes some data,
>> and add custom attribute to the model. Thing is, I do not know how could I
>> raise an exception if this functions that are accessed when the template is
>> generated (the error seems to be only silent, so it will process the
>> template further but gives NO ERROR )
>>
>> In the template
>>     {{ entry.state }}
>>
>> In the model:
>>
>>     @property
>>     def state(self):
>>         somedict = {'a': 111}
>>         try:
>>            print somedict['b']
>>         except Exception as e:
>>            FATAL_ERROR
>>
>> What should I put in the place of fatal_error so that the template
>> processing should stop immediatelly, or gives some exception to the render
>> function ?
>> Thanks
>>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to