How to change django datetime format output?

前端 未结 1 447
感情败类
感情败类 2020-12-15 23:13

I have a datetime object. This is my template file:

  • {{ sale.validity }}

and the output i\'m get

相关标签:
1条回答
  • 2020-12-15 23:36

    Per Django docs, you can use a date filter to format date:

    {{ sale.validity|date:"d-m-Y"}} 
    

    Additionally, you can also set DATE_FORMAT (or DATETIME_FORMAT) setting to set a project-wide default for displaying such values if USE_L10N is False. If it's true, you'll want to have a look at this documentation on format localization.

    0 讨论(0)
提交回复
热议问题