python - 从管理页面隐藏 django-allauth 模型

标签 python django django-admin django-allauth django-3.1

我想从管理页面隐藏所有 django-allauth 模型

enter image description here

在我看到github中的源代码之后我看到它使用三种模型 SocialAccountSocialTokenSocialApp

现在我使用 this从管理页面隐藏模型,当我尝试在我自己的模型上使用它时它可以工作但是 当我用它来隐藏 django-allauth 模型时它不起作用,我想我停留在 from x import SocialAccount, SocialToken, SocialApp

部分

因为错误信息总是这样

ImportError: cannot import name 'SocialAccount' from 'x'

我不知道x部分要导入什么,导入哪里

最佳答案

这有效。

from allauth.socialaccount.models import SocialAccount, SocialApp, SocialToken

admin.site.unregister(SocialAccount)
admin.site.unregister(SocialApp)
admin.site.unregister(SocialToken)

关于python - 从管理页面隐藏 django-allauth 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65412702/

相关文章:

python - 是否可以在 django 管理站点中更改模型名称?

python - 从 AllenSDK 运行 Cell Types 笔记本时出现类型错误

python - 字符串以特定文本开头

python - 不支持在 include() 中指定命名空间而不提供 app_name

python - Django auto_now 和 auto_now_add

django - 如何向 Django 用户管理页面添加操作?

C++调用python脚本来处理电子邮件

python - 为什么在 pandas 中除以 0 时会得到 infs?

python - Django 将项目路径存储在哪里?

ajax - 带有Django(或任何网络框架)的AJAX的 "best practices"是什么