diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index ea49c19..e65bfdc 100644
a
|
b
|
class NowNode(Node):
|
381 | 381 | |
382 | 382 | def render(self, context): |
383 | 383 | from datetime import datetime |
384 | | from django.utils.dateformat import DateFormat |
385 | | df = DateFormat(datetime.now()) |
386 | | return df.format(self.format_string) |
| 384 | from django.utils import formats |
| 385 | from django.utils import dateformat |
| 386 | now = datetime.now() |
| 387 | try: |
| 388 | return formats.date_format(now, self.format_string) |
| 389 | except AttributeError: |
| 390 | try: |
| 391 | return dateformat.format(now, self.format_string) |
| 392 | except AttributeError: |
| 393 | return '' |
387 | 394 | |
388 | 395 | class SpacelessNode(Node): |
389 | 396 | def __init__(self, nodelist): |
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 1767b5b..c607015 100644
a
|
b
|
escaped, because it's not a format character::
|
727 | 727 | |
728 | 728 | This would display as "It is the 4th of September". |
729 | 729 | |
| 730 | The format passed can also be one of the predefined ones ``DATE_FORMAT``, |
| 731 | ``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``. Note |
| 732 | that predefined formats may vary depending on the current locale. |
| 733 | |
730 | 734 | .. templatetag:: regroup |
731 | 735 | |
732 | 736 | regroup |
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 75f3b4f..abfdb8d 100644
a
|
b
|
from django.template.loaders import app_directories, filesystem, cached
|
21 | 21 | from django.test.utils import get_warnings_state, restore_warnings_state,\ |
22 | 22 | setup_test_template_loader, restore_template_loaders |
23 | 23 | from django.utils import unittest |
| 24 | from django.utils.formats import date_format |
24 | 25 | from django.utils.translation import activate, deactivate, ugettext as _ |
25 | 26 | from django.utils.safestring import mark_safe |
26 | 27 | from django.utils.tzinfo import LocalTimezone |
… |
… |
class Templates(unittest.TestCase):
|
1422 | 1423 | 'now02': ('{% now "j "n" Y"%}', {}, template.TemplateSyntaxError), |
1423 | 1424 | # 'now03': ('{% now "j \"n\" Y"%}', {}, str(datetime.now().day) + '"' + str(datetime.now().month) + '"' + str(datetime.now().year)), |
1424 | 1425 | # 'now04': ('{% now "j \nn\n Y"%}', {}, str(datetime.now().day) + '\n' + str(datetime.now().month) + '\n' + str(datetime.now().year)) |
| 1426 | # Check parsing of locale strings |
| 1427 | 'now05': ('{% now "DATE_FORMAT" %}', {}, date_format(datetime.now())), |
1425 | 1428 | |
1426 | 1429 | ### URL TAG ######################################################## |
1427 | 1430 | # Successes |