请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

value has an invalid date format. It must be in YYYY-MM-DD format错误怎么解决?

创建超级用户输入完用户名 邮箱 密码 回车,这时报了一个错误:
Traceback (most recent call last):
File “manage.py”, line 22, in
execute_from_command_line(sys.argv)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\core\management_init_.py”, line 364, in execute_from_command_line

utility.execute()

File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\core\management_init_.py”, line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\core\management\base.py”, line 283, in run_from_argv
self.execute(*args, **cmd_options)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\contrib\auth\management\commands\createsuperuser.py”, line 63, in ex
ecute
return super(Command, self).execute(*args, **options)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\core\management\base.py”, line 330, in execute
output = self.handle(*args, **options)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\contrib\auth\management\commands\createsuperuser.py”, line 183, in h
andle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\contrib\auth\models.py”, line 170, in create_superuser
return self._create_user(username, email, password, **extra_fields)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\contrib\auth\models.py”, line 153, in _create_user
user.save(using=self._db)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\contrib\auth\base_user.py”, line 80, in save
super(AbstractBaseUser, self).save(*args, **kwargs)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\base.py”, line 808, in save
force_update=force_update, update_fields=update_fields)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\base.py”, line 838, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\base.py”, line 924, in _save_table
result = self.do_insert(cls.base_manager, using, fields, update_pk, raw)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\base.py”, line 963, in do_insert
using=using, raw=raw)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\manager.py”, line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\query.py”, line 1079, in insert
return query.get_compiler(using=using).execute_sql(return_id)
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\sql\compiler.py”, line 1111, in execute_sql
for sql, params in self.as_sql():
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\sql\compiler.py”, line 1064, in as_sql
for obj in self.query.objs
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\sql\compiler.py”, line 1064, in
for obj in self.query.objs
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\sql\compiler.py”, line 1063, in
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
File “D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\sql\compiler.py”, line 1003, in prepare_value
value = field.get_db_prep_save(value, connection=self.connection)
File "D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\fields_init
.py", line 770, in get_db_prep_save
prepared=False)
File "D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\fields_init
.py", line 1301, in get_db_prep_value
value = self.get_prep_value(value)
File "D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\fields_init
.py", line 1296, in get_prep_value
return self.to_python(value)
File "D:\Python3.6.7\lib\site-packages\django-1.11.20-py3.6.egg\django\db\models\fields_init
.py", line 1271, in to_python
params={‘value’: value},
django.core.exceptions.ValidationError: ["’’ value has an invalid date format. It must be in YYYY-MM-DD format."]
这怎么解决呢?搞不懂啊

正在回答 回答被采纳积分+3

2回答

bobby 2019-03-13 13:56:36

你的birthday可以设置为可以为none, 不然用createsuperuser命令新建的用户这个字段必填的话格式就会出错

0 回复 有任何疑惑可以回复我~
Ethreal 2019-03-12 18:48:37

和源码对比一下 是不是时间字段写错了?model模型的

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号