python - 日期的默认格式

标签 python django gettext

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

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

但是当我有一个大的 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/

相关文章:

python - 通过 Babel 国际化 Python 2.6 应用程序

python - 如何设置元素数量等于另一列列表中元素数量的列列表

python - UTF8-in 文字和 unicode 点之间有什么区别?

python - 如何快速解析出字典键中该字符串的前缀?

Django 转储数据输出为空

django - 如何在 Amazon S3 中使用 django-photologue?解决 NotImplementedError

python - 带有 Flask 'mongoengine.errors.NotRegistered' 问题的 mongoengine

具有远程 jwt 身份验证的 Django REST

php gettext调试

c# - 我可以限制 C# 函数仅接受字符串文字吗?