Python Django createsuperuser表示密钥已存在
我对如何从终端使用“python manage.py createsuperuser”命令感到困惑 当我运行这个命令时,它会说 django.db.utils.IntegrityError:重复的键值违反唯一约束“authtoken\u token\u user\u id\u key” 详细信息:密钥(用户id)=(abcdef@gmail.com)已经存在 但是,在使用这个命令之前,我删除了migrations目录中的000*个文件,然后删除了数据库并重新创建 我检查了authtoken\u令牌和用户表中是否没有行。 我不知道怎么了 请给我一些建议Python Django createsuperuser表示密钥已存在,python,django,python-3.x,django-models,Python,Django,Python 3.x,Django Models,我对如何从终端使用“python manage.py createsuperuser”命令感到困惑 当我运行这个命令时,它会说 django.db.utils.IntegrityError:重复的键值违反唯一约束“authtoken\u token\u user\u id\u key” 详细信息:密钥(用户id)=(abcdef@gmail.com)已经存在 但是,在使用这个命令之前,我删除了migrations目录中的000*个文件,然后删除了数据库并重新创建 我检查了authtoken\u令
(remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py makemigrations
(remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py migrate
(remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py dbshell
psql (9.5.8)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
remoshin_maindb=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------------------------------------------+-------+---------
public | auth_group | table | remosys
public | auth_group_permissions | table | remosys
public | auth_permission | table | remosys
public | authtoken_token | table | remosys
public | django_admin_log | table | remosys
public | django_content_type | table | remosys
public | django_migrations | table | remosys
public | django_session | table | remosys
public | remosys_chat_detail_tbl | table | remosys
public | remosys_chat_tbl | table | remosys
public | remosys_clinic_ipaddress_tbl | table | remosys
public | remosys_clinic_open_tbl | table | remosys
public | remosys_clinic_tbl | table | remosys
public | remosys_consultation_menu_tbl | table | remosys
public | remosys_consultation_tbl | table | remosys
public | remosys_department_tbl | table | remosys
public | remosys_error_tbl | table | remosys
public | remosys_menu_tbl | table | remosys
public | remosys_refund_request_tbl | table | remosys
public | remosys_remoshin_doctor_tbl | table | remosys
public | remosys_remoshin_manager_tbl | table | remosys
public | remosys_remoshin_manager_tbl_groups | table | remosys
public | remosys_remoshin_manager_tbl_user_permissions | table | remosys
public | remosys_remoshin_user_tbl | table | remosys
public | remosys_statement_tbl | table | remosys
(25 rows)
remoshin_maindb=# select * from authtoken_token;
key | created | user_id
-----+---------+---------
(0 rows)
remoshin_maindb=# select * from remosys_remoshin_user_tbl;
remoshin_maindb=# select * from authtoken_token_user_id_key";
remoshin_maindb"# select max(id) from authtoken_token_user_id_key;
remoshin_maindb"#
remoshin_maindb=# \q
(remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py createsuperuser
(omit)
File "/home/ubuntu/remoshin/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
psycopg2.IntegrityError: duplicate key value violates unique constraint "authtoken_token_user_id_key"
DETAIL: Key (user_id)=(abcdef@gmail.com) already exists.