【问题标题】:How to edit the Django Admin User social auths listing page?如何编辑 Django 管理员用户社交身份验证列表页面?
【发布时间】:2020-06-18 16:07:28
【问题描述】:
【问题讨论】:
标签:
django
django-admin
django-socialauth
【解决方案1】:
好的,这就是我尝试使用 Django-allauth 的方法,我认为它与 django-socialauth 的工作方式相同。只需了解想法的要点并将其应用于您的代码即可
首先在您的任何 admin.py 文件中扩展 SocialAccountAdmin,最好在“user”、“home”等特定应用中",或者任何你喜欢的。
admin.py
from allauth.socialaccount.admin import SocialAccountAdmin
from allauth.socialaccount.models import SocialAccount
class MySocialAccount(SocialAccountAdmin):
list_display = ('user', 'uid', 'provider', 'date_joined') # I haven't tried just adding a certain list to the list_display, for the meantime add all necessary fields just like how socialauth did
admin.site.unregister(SocialAccount) # Need to unregister the default socialaccount admin
admin.site.register(SocialAccount, MySocialAccount) # Then register it back with the custom made admin
也许有更好的方法可以做到这一点,但这确实奏效了。