psql insert into能插入 django调用CAS新建用户出现duplicate key value violates unique constraint

django.db.utils.IntegrityError: duplicate key value violates unique constraint “users_user_username_key”
DETAIL: Key (username)=(xxx) already exists
索引问题吗?

没太听懂怎么导致的,能详细描述一下执行的什么操作码

File “/opt/py3/lib/python3.11/site-packages/django/db/models/base.py”, line 863, in save_base
updated = self._save_table(
^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/models/base.py”, line 1006, in _save_table
results = self._do_insert(
^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/models/base.py”, line 1047, in _do_insert
return manager._insert(
^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/models/manager.py”, line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/models/query.py”, line 1791, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/models/sql/compiler.py”, line 1660, in execute_sql
cursor.execute(sql, params)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 84, in _execute
with self.db.wrap_database_errors:
File “/opt/py3/lib/python3.11/site-packages/django/db/utils.py”, line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 91, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.IntegrityError: duplicate key value violates unique constraint “users_user_username_key”
DETAIL: Key (username)=(xxx) already exists.
在做CAS认证的时候,扫完码后端的报错 前端报 Server error occur, contact administrator

是不是cas映射的用户名已经存在了,把那个本地用户干了,或者cas用户名改名。堡垒机不允许不同来源相同用户名存在

CAS映射配置的这个
{
“username”: “username”
}

postgresql 里面users_user表里没有这个xxx用户


看下这里是开启的还是关闭的,可以关闭试试


这个一直都是关的

去开源微信群问

这个在哪里呀

JumpServer - 开源堡垒机 - 官网滑到页面最下方有技术交流群二维码,我不一定在那个群里,但是有别的大佬在直接问