Opened 17 years ago
Closed 17 years ago
#10486 closed (duplicate)
DateTimeFormat in admin doesn't use DATETIME_FORMAT from settings
| Reported by: | Evgeniy Ivanov | Owned by: | nobody |
|---|---|---|---|
| Component: | Translations | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I have set DATETIME_FORMAT in the settings. I have 2 models with OneToMany relation (one has datetime and another uses fk to get datetime). In admin I get correct datetime for model, which uses function returning fk.some_datetime. Format in model containing datetime is wrong.
After checking I noticed it comes from utils.translation.get_date_formats:
datetime_format = ugettext('DATETIME_FORMAT')
...
if datetime_format == 'DATETIME_FORMAT':
datetime_format = settings.DATETIME_FORMAT #is never set for me
I have default localization: "LANGUAGE_CODE = 'en-us'" in settings.
Change History (4)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Regarding your original report, it would be very useful if you post: a) A minimal example of the model(s) you describe and b) if you can, the value of the if datetime_format variable at the if datetime_format == 'DATETIME_FORMAT': line because if you are using en-us at that point its valus should be 'DATETIME_FORMAT'.
comment:3 by , 17 years ago
| Component: | django.contrib.admin → Translations |
|---|
Here it is. Somebody has translated all things...
>>> from django.utils import dateformat >>> from django.utils.translation import get_date_formats >>> (date_format, datetime_format, time_format) = get_date_formats() >>> datetime_format u'N j, Y, P' >>> datetime_format == 'DATETIME_FORMAT' False >>> from django.conf import settings >>> settings.DATETIME_FORMAT 'Y-m-d H:i:s'
Coolest model ever, but listing above had made all things clear:
class MTest(models.Model):
datetime = models.DateTimeField() #adminModel should show it
About models with fk and seconds I was wrong, so don't mind about FKs and seconds.
I've noticed, I still have a problem with seconds. I've commented 'if datetime_format == 'DATETIME_FORMAT':', so DATETIME_FORMAT is taken from settings.py, but seconds look like '18:01:23.653000'...