简体   繁体   中英

django naturaltime returning the same result

In my model i have a fields like : 

time = models.DateTimeField(auto_now_add=True)

In view page i am getting the value like in this format :

2020-03-15T11:07:07.089Z

I am getting the date time in this format.

{{ result.time|naturaltime }}

but its not working it returning me the same date whick is comming from the data base

You should use DateField instead of DateTimeField . Like : time = models.DateField(auto_now_add=True) here is a link for django fields(for more clarity) : https://docs.djangoproject.com/en/2.2/ref/models/fields/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM