1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #29288 -- Made {% widthratio %} assign to as var if an exception occurs.

This commit is contained in:
Jirka Vejrazka
2018-04-04 20:03:16 +02:00
committed by Tim Graham
parent 9fd9f8bbb2
commit 6148dda72f
2 changed files with 12 additions and 2 deletions

View File

@@ -483,9 +483,9 @@ class WidthRatioNode(Node):
ratio = (value / max_value) * max_width
result = str(round(ratio))
except ZeroDivisionError:
return '0'
result = '0'
except (ValueError, TypeError, OverflowError):
return ''
result = ''
if self.asvar:
context[self.asvar] = result