diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 673d044..7db6715 100644
a
|
b
|
def date(value, arg=None):
|
681 | 681 | return u'' |
682 | 682 | if arg is None: |
683 | 683 | arg = settings.DATE_FORMAT |
684 | | return format(value, arg) |
| 684 | try: |
| 685 | return format(value, arg) |
| 686 | except AttributeError: |
| 687 | return '' |
685 | 688 | date.is_safe = False |
686 | 689 | |
687 | 690 | def time(value, arg=None): |
… |
… |
def time(value, arg=None):
|
691 | 694 | return u'' |
692 | 695 | if arg is None: |
693 | 696 | arg = settings.TIME_FORMAT |
694 | | return time_format(value, arg) |
| 697 | try: |
| 698 | return time_format(value, arg) |
| 699 | except AttributeError: |
| 700 | return '' |
695 | 701 | time.is_safe = False |
696 | 702 | |
697 | 703 | def timesince(value, arg=None): |
diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py
index 91afdc7..e8b1dbe 100644
a
|
b
|
def get_filter_tests():
|
320 | 320 | 'join02': (r'{% autoescape off %}{{ a|join:", " }}{% endautoescape %}', {'a': ['alpha', 'beta & me']}, 'alpha, beta & me'), |
321 | 321 | 'join03': (r'{{ a|join:" & " }}', {'a': ['alpha', 'beta & me']}, 'alpha & beta & me'), |
322 | 322 | 'join04': (r'{% autoescape off %}{{ a|join:" & " }}{% endautoescape %}', {'a': ['alpha', 'beta & me']}, 'alpha & beta & me'), |
| 323 | |
| 324 | |
| 325 | 'date01': (r'{{ d|date:"m" }}', {'d': datetime(2008, 1, 1)}, '01'), |
| 326 | 'date02': (r'{{ d|date }}', {'d': datetime(2008, 1, 1)}, 'Jan. 1, 2008'), |
| 327 | #Ticket 9520: Make sure |date doesn't blow up on non-dates |
| 328 | 'date03': (r'{{ d|date:"m" }}', {'d': 'fail_string'}, ''), |
323 | 329 | } |