How do I make Django's DATETIME_FORMAT active?

前端 未结 4 1994
渐次进展
渐次进展 2021-02-13 23:49

Where should DATETIME_FORMAT be placed for it to have effect on the display of date-time in the Django admin site (Django’s automatic admin interface)?

Documentation for

4条回答
  •  有刺的猬
    2021-02-14 00:12

    The two setting directives should be defined in settings.py. Could you ensure that the same settings.py that you are editing is being read when you start the development server?

    You could always drop to the Python interactive shell by running python manage.py shell, and run these commands to ensure whether the date/time format values are getting through fine:

    from django.conf import settings
    settings.DATE_FORMAT
    settings.DATETIME_FORMAT
    

    Ok, I forgot to look it up, but ticket #2203 deals with this. Unfortunately, the ticket remains in pending state.

    I remember that for a project that used a certain trunk revision of the 0.97 branch of Django, I worked around that by overwriting the date_format and datetime_format values in the get_date_formats() function inside django/utils/translation/trans_real.py. It was dirty, but I had already been using a custom Django of sorts for that project, so didn't see anything going wrong in hacking it trifle more.

提交回复
热议问题