The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\core\management\__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 63, in execu
te
return super(Command, self).execute(*args, **options)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 183, in hand
le
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\contrib\auth\models.py", line 170, in create_superuser
return self._create_user(username, email, password, **extra_fields)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\contrib\auth\models.py", line 153, in _create_user
user.save(using=self._db)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\contrib\auth\base_user.py", line 80, in save
super(AbstractBaseUser, self).save(*args, **kwargs)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\base.py", line 808, in save
force_update=force_update, update_fields=update_fields)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\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:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\base.py", line 924, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\base.py", line 963, in _do_insert
using=using, raw=raw)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\query.py", line 1076, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\models\sql\compiler.py", line 1112, in execute_sql
cursor.execute(sql, params)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Dpan\Class_Software\Miniconda3\envs\meiduo\lib\site-packages\django\db\backends\mysql\base.py", line 101, in execute
return self.cursor.execute(query, args)
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\cursors.py", line 170, in execute
result = self._query(query)
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\cursors.py", line 328, in _query
conn.query(q)
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\connections.py", line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\connections.py", line 732, in _read_query_result
result.read()
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\connections.py", line 1075, in read
first_packet = self.connection._read_packet()
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\connections.py", line 684, in _read_packet
packet.check_error()
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "C:\Users\Jason\AppData\Roaming\Python\Python36\site-packages\pymysql\err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.IntegrityError: (1062, "Duplicate entry '' for key 'mobile'")
问题分析:
众所周知我们创建后台管理员时候是没有设置手机号的
报这个错就是告诉我们在数据库中已经存在一个管理员,且手机号为空,
我们再次创建管理员就会有手机号重复的现象存在从而报这个错
django.db.utils.IntegrityError: (1062, "Duplicate entry 'gkate' for key 'username'")