django.db.utils.DataError: (1406, "Data too long for column 'gender' at row 1")
报错现象
在使用 django 创建 超级用户的时候提示报错

Password (again): ytyt521521
Traceback (most recent call last):
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\mysql\base.py", line 112, in execute
return self.cursor.execute(query, args)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
res = self._query(query)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\cursors.py", line 312, in _query
db.query(q)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.DataError: (1406, "Data too long for column 'gender' at row 1") The above exception was the direct cause of the following exception: Traceback (most recent call last):
File "D:\PyCharm 2018.2.5\helpers\pycharm\django_manage.py", line 52, in <module>
run_command()
File "D:\PyCharm 2018.2.5\helpers\pycharm\django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "c:\python36\Lib\runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "c:\python36\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "c:\python36\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:/Users/Python/PycharmProjects/MxOnline\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 52, in execute
return super(Command, self).execute(*args, **options)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 173, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\contrib\auth\models.py", line 165, in create_superuser
return self._create_user(username, email, password, **extra_fields)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\contrib\auth\models.py", line 148, in _create_user
user.save(using=self._db)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\contrib\auth\base_user.py", line 74, in save
super(AbstractBaseUser, self).save(*args, **kwargs)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\base.py", line 708, in save
force_update=force_update, update_fields=update_fields)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\base.py", line 736, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\base.py", line 820, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\base.py", line 859, in _do_insert
using=using, raw=raw)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\query.py", line 1039, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\models\sql\compiler.py", line 1060, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\django\db\backends\mysql\base.py", line 112, in execute
return self.cursor.execute(query, args)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
res = self._query(query)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\cursors.py", line 312, in _query
db.query(q)
File "C:\Users\Python\Envs\testvir2\lib\site-packages\MySQLdb\connections.py", line 224, in query
_mysql.connection.query(self, query)
django.db.utils.DataError: (1406, "Data too long for column 'gender' at row 1")
全部报错代码
分析报错
没有具体的跳转, 但是文本是 gender 的问题因此可以断定是 gender 的长度问题
找到 所含 gender 的字段, 发现 长度确实有点小. female 是 6 位 超出了.因此报错

报错处理
更改 长度 为 10 然后 记得上传表更改之后再重新创建即可

django.db.utils.DataError: (1406, "Data too long for column 'gender' at row 1")的更多相关文章
- 报错pymysql.err.DataError: (1406, "Data too long for column 'gender' at row 1")
在Django默认的admin后台创建超级用户时, 报错pymysql.err.DataError: (1406, "Data too long for column 'gender' at ...
- mysql修改字段长度及pymysql.err.DataError: (1406, "Data too long for column 'name' at row 1")错误
文章链接:修改字段:https://blog.csdn.net/xiejunna/article/details/78580682 错误分析:https://blog.csdn.net/qq_4214 ...
- 数据导入问题:[Err] [Imp] 1406 - Data too long for column 'linkman' at row 20 [Err] [Imp] INSERT INTO `excel_eprinfo`
导入数据:提示错误 [Err] [Imp] 1406 - Data too long for column 'linkman' at row 20[Err] [Imp] INSERT INTO `ex ...
- Data truncation: Data too long for column 'gender' at row 1 出现的原因
创建数据库的代码如下: create database day15 ; use day15 ; create table customer( id varchar(100) primary key, ...
- SSM整合中错误:Data truncation: Data too long for column 'gender' at row 1
错误描述 ### SQL: insert into t_customer(name,gender,phone,address) values (?,?,?,?) ### Cause: com.mysq ...
- 1406 data too long for column 'content' at row 1
很奇怪,很邪门. content字段用的是text格式,按理说不会出现数据太长的问题. 后来搜索了一下,需要设置sql_mode.或者设为, mysql> SET @@global.sql_mo ...
- 成功解决1406, “Data too long for column ‘txt‘ at row 1“
这是因为数据库里该字段的数据类型所给的数据空间太小.MySQL将截断超过指定列宽度的任何插入值.为了让这个不报错,可以尝试切换MySQL模式不使用严格模式. SET @@global.sql_mode ...
- 报错:Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'gender' at row 1
我遇到这个错误是解决办法:我修改了对应的数据库字段的长度:原本我设置的是char型,但是存进去的是一个string型,结果就报了这个报了这个错误 下面就是数据库修改之后的结果. 以上都是我学习过程中遇 ...
- SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'dtdate' 解决方法
小微OAERR: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'mime' at row ...
随机推荐
- 面试题-如何测试一个APP
问: 假如给你一个APP,你应该如何测试,分别从哪些方面来针对该APP进行测试. --- 1.安装.卸载测试 测试软件在不同操作系统(Android.iOS)下安装是否正常.软件安装后的是否能够正常运 ...
- Elasticsearch 关键字:索引,类型,字段,索引状态,mapping,文档
1. 索引(_index)索引:说的就是数据库的名字.我这个说法是对应到咱经常使用的数据库. 结合es的插件 head 来看. 可以看到,我这个地方,就有这么几个索引,索引就是数据库,后面是这个数据库 ...
- JavaScript对象访问器属性
对象访问器就是setter和getter,他们的作用就是 提供另外一种方法来获取或者设置对象的属性值, 并且在获取和设置的时候,可以用一定的其他操作. 看下面代码: <script> va ...
- 我的第一个Go web程序 纪念一下
参考Go web编程,很简单的程序: 大致的步骤: 绑定ip和端口 绑定对应的处理器或者处理器函数,有下面两种选择,选择一种即可监听ip及端口 处理器: 定义一个struct结构体 然后让这个结构体实 ...
- 【学习总结】Git学习-参考廖雪峰老师教程-期末总结
学习总结之Git学习-总 目录: 一.Git简介 二.安装Git 三.创建版本库 四.时光机穿梭 五.远程仓库 六.分支管理 七.标签管理 八.使用GitHub 九.使用码云 十.自定义Git 期末总 ...
- windows 内建环境变量
PS C:\Windows> ls env: Name Value ---- ----- _NT_SYMBOL_PATH srv*C:\Users\vv\Documents\symbols AL ...
- babel(一)
一.babel npm babel src/index.js -d lib 二.@babel/core @babel/cli @babel/core 转换语法核心 @babel/cli 执行 ...
- IIS 使用 HTTP重定向 修改 默认主页
1. 被自己坑死了 多了一个 正斜杠 浪费了好长好长的时间 2. 需求 直接输入ip地址 总是 弹出来 iis 的 welcome的界面 感觉很low 想要修改一下 曾经用过 reflesh 来修改过 ...
- rpm和yum
RMP(红帽软件包管理器) RPM有点像Windows系统中的控制面板,会建立统一的数据库文件,详细记录软件信息并能够自动分析依赖关系. YUM(软件仓库)
- Flutter的输入框TextField
TextFiled组件的API 先来看一下TextFiled的构造方法: const TextField({ Key key, this.controller, this.focusNode, thi ...