Python Django DateTimeField ValidationError:值的格式无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37386312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:20:02  来源:igfitidea点击:

Django DateTimeField ValidationError: value has an invalid format

pythondjangodjango-models

提问by Yunti

I'm getting a validation error when trying to store a date time in a django DateTimeField.

尝试在 django DateTimeField 中存储日期时间时出现验证错误。

The format I'm trying to save is below, together with the error. :

我试图保存的格式如下,以及错误。:

django.core.exceptions.ValidationError: ["'Mon, 23 May 2016 08:30:15 GMT' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][T

In my django settings I have:

在我的 Django 设置中,我有:

DATE_INPUT_FORMATS = ("%d %b %Y", )

Should I be converting the format before saving or can I add to DATE_INPUT_FORMATS

我应该在保存之前转换格式还是可以添加到 DATE_INPUT_FORMATS

回答by ImportError

Django references: DateTimeField

Django 参考:DateTimeField

Here's the answer: StackOverflow Answer Reference

这是答案:StackOverflow 答案参考