summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-06 23:49:03 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-06 23:49:03 +0000
commitd4df074d418ce61b9fca3df7ce887e7a5f54b01f (patch)
tree3c854ba80df0bba51a1229a6b71592534ca0809b /django
parent72547994c12bd77b804e7e9a03c94ca80988cc44 (diff)
Fixed #109 -- Created DATE_FORMAT, DATETIME_FORMAT and TIME_FORMAT settings.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1115 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/conf/global_settings.py12
-rw-r--r--django/contrib/admin/views/main.py12
2 files changed, 19 insertions, 5 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index b8d4d06e58..a95a956234 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -154,6 +154,18 @@ MEDIA_ROOT = ''
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
+# Default formatting for date objects. See all available format strings here:
+# http://www.djangoproject.com/documentation/templates/#now
+DATE_FORMAT = 'N j, Y'
+
+# Default formatting for datetime objects. See all available format strings here:
+# http://www.djangoproject.com/documentation/templates/#now
+DATETIME_FORMAT = 'N j, Y, P'
+
+# Default formatting for time objects. See all available format strings here:
+# http://www.djangoproject.com/documentation/templates/#now
+TIME_FORMAT = 'P'
+
##############
# MIDDLEWARE #
##############
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index b188f58947..c4bbee633f 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -10,7 +10,7 @@ from django.models.admin import log
from django.utils.html import strip_tags
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.utils.text import capfirst, get_text_list
-from django.conf.settings import ADMIN_MEDIA_PREFIX
+from django.conf.settings import ADMIN_MEDIA_PREFIX, DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT
import operator
# Text to display within changelist table cells if the value is blank.
@@ -401,13 +401,15 @@ def change_list(request, app_label, module_name):
result_repr = getattr(result, 'get_%s' % f.name)()
else:
result_repr = EMPTY_CHANGELIST_VALUE
- # Dates are special: They're formatted in a certain way.
- elif isinstance(f, meta.DateField):
+ # Dates and times are special: They're formatted in a certain way.
+ elif isinstance(f, meta.DateField) or isinstance(f, meta.TimeField):
if field_val:
if isinstance(f, meta.DateTimeField):
- result_repr = dateformat.format(field_val, 'N j, Y, P')
+ result_repr = capfirst(dateformat.format(field_val, DATETIME_FORMAT))
+ elif isinstance(f, meta.TimeField):
+ result_repr = capfirst(dateformat.time_format(field_val, TIME_FORMAT))
else:
- result_repr = dateformat.format(field_val, 'N j, Y')
+ result_repr = capfirst(dateformat.format(field_val, DATE_FORMAT))
else:
result_repr = EMPTY_CHANGELIST_VALUE
row_class = ' class="nowrap"'