You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Django添加社交应用遇IntegrityError:provider_id列非空约束违规

Django Allauth添加Google社交应用触发IntegrityError问题

问题现象

通过Django admin面板添加Google社交应用时,触发IntegrityError,错误提示provider_id列存在空值,违反非空约束。当前provider仅Google一个可选,且已执行所有数据库迁移。

Google OAuth配置详情

已配置正确的授权重定向URI,应用发布状态为生产环境。

排查背景

已按照YouTube教程《Set up Google Sign-in for Faster Django Login Experience Feat. Tech with Tim》的步骤实现Google OAuth,问题出现在教程23:06左右添加社交账号的环节;同时已参考Django官方文档,settings.py中的OAuth配置未发现明显问题。

代码排查情况

  • codestar/settings.py:已严格检查拼写,尝试过不同版本的SOCIALACCOUNT_PROVIDERS配置,暂未发现问题
  • users/models.py:当前为空文件

Django Admin站点情况

添加社交应用时有两个可选站点:http://127.0.0.1:8000 和 GitPod在线开发地址,未发现异常。

错误详情

IntegrityError at /admin/socialaccount/socialapp/add/
null value in column "provider_id" violates not-null constraint
DETAIL: Failing row contains (8, google, google, 888982092733-51qdar9ln6i5onjoli2blj9bb6$$$$$$$.apps.googleusercon..., GOCSPX-im5A3HBsy_5FFvJTKqz$$$$$$$, , null, null).

内容的提问来源于stack exchange,提问作者Laurie Crean

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 06:24:52