gpt4 book ai didi

python - 日期的默认格式

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:14 24 4
gpt4 key购买 nike

我知道 Django 过滤器“date”,它允许在模板中格式化日期。

我知道我可以修改特定模型中特定字段的表示。

但是当我有一个大的 Django 项目并且想要保持日期格式以一致的方式显示在模板中时 - 有没有可能通过设置来实现这一点?如果不是,还有其他可能性吗?

我想到的最简单的解决方案是编写自己的模板标签来显示日期并使用它,但也许是我错过的显而易见的事情。

如果这个日期的格式可以根据语言环境而变化,那就太好了......

最佳答案

确保检查影响日期表示的设置。

特别是DATE_FORMAT

The default formatting to use for displaying date fields in any part of the system

DATETIME_FORMAT

The default formatting to use for displaying datetime fields in any part of the system. Note that if USE_L10N is set to True, then the locale-dictated format has higher precedence and will be applied instead

关于python - 日期的默认格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5882693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com