Save date in django in desired format

泪湿孤枕 提交于 2020-01-17 07:53:11

问题


I want to save date in my django model into desired format.

post_date = str(request.POST['date'])

I am getting date from front end is 12/21/2016 i want to save this date in my django modal is like 21-Dec-2016.

How can i do it. it will be good if you can provide some sample code.

Thanks in advance.


回答1:


you want to store in DB string parameter? The easiest way convert input string to date and then convert from date to string. But of course it is more logical to store date format imho



来源:https://stackoverflow.com/questions/41140317/save-date-in-django-in-desired-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!