我知道 Django 过滤器“日期”,它允许在模板中格式化日期。
我知道我可以修改特定模型中特定字段的表示。
但是当我有一个大的 Django 项目并且希望保持日期格式以一致的方式在模板中显示时 - 是否有可能通过设置来实现这一点?如果没有,还有其他可能性吗?
我想到的最简单的解决方案是编写自己的模板标签来显示日期并使用它,但也许是我错过的明显的东西。
如果该日期格式可以根据区域设置而变化,那就太好了......
最佳答案
确保检查影响日期表示的设置。
特别是DATE_FORMAT
The default formatting to use for displaying date fields in any part of the system
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/