Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Option to suppress exceptions with templatetags #288

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant

I have code like this in the template:

{% thumbnail '588x344' idea.image as thumb %}
<img src="{{ thumb.url }}" alt="{{ idea.title }}" image-ratio />

This will cause a 500 error if the source image is missing. This commonly happens during development when the database and media dir get out of sync.

IMHO there should be a way for this to easily return a 404, converting it from an error which completely breaks the page into a more appropriate 'broken image' icon from the browser.

hmm, well it's hard to do that without swallowing all the debugging info

being able to specify a default fallback image for missing src would be handy though

this was the simplest fix I could find - a flag on the exception class that allow Django template engine to suppress the exception

it means {{ thumb.url }} goes through as empty string, but at least I can render my page and see which image was even missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment