Format a date according to the given format.
(value, arg=None)
| 783 | |
| 784 | @register.filter(expects_localtime=True, is_safe=False) |
| 785 | def date(value, arg=None): |
| 786 | """Format a date according to the given format.""" |
| 787 | if value in (None, ""): |
| 788 | return "" |
| 789 | try: |
| 790 | return formats.date_format(value, arg) |
| 791 | except AttributeError: |
| 792 | try: |
| 793 | return format(value, arg) |
| 794 | except AttributeError: |
| 795 | return "" |
| 796 | |
| 797 | |
| 798 | @register.filter(expects_localtime=True, is_safe=False) |