[patch] date, time, and timesince filters don't fail silently
if you have something like
{{ event.due_date|date:"F j, Y" }}
in your template, and the date/time field is None, then the template will raise AttributeError
:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in render_node
698. result = node.render(context)
File "/usr/lib/python2.4/site-packages/django/template/defaulttags.py" in render
113. nodelist.append(node.render(context))
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in render
744. output = self.filter_expression.resolve(context)
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in resolve
556. obj = func(obj, *arg_vals)
File "/usr/lib/python2.4/site-packages/django/template/defaultfilters.py" in date
356. return format(value, arg)
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in format
252. return df.format(format_string)
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in format
27. pieces.append(str(getattr(self, piece)()))
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in F
123. return MONTHS[self.data.month]
AttributeError at /home/
'NoneType' object has no attribute 'month'
Change History
(6)
Summary: |
date, time, and timesince filters don't fail silently → [patch] date, time, and timesince filters don't fail silently
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Resolution: |
fixed
|
Status: |
closed → reopened
|
Resolution: |
→ fixed
|
Status: |
reopened → closed
|
Just would like to note that a decorator could be used instead if you do one of:
A decorator that returns an empty string when
value
isNone
might be useful to other filters also.