如何编辑Django Admin用户社交认证列表页面?

问题描述 投票:0回答:2

我在查找此管理文件的位置时遇到了麻烦,因此我可以添加一个额外的字段。我认为它是在安装时自动创建的。

我想在UID字段之后,特别是在列表页面(如下所示)上添加一个日期字段,以便我可以知道何时创建用户auth。

screenshot of django user social auths listing page

django django-admin django-socialauth
2个回答
0
投票

好的,这就是我尝试使用的[[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

也许也许有更好的方法可以做到这一点,但这确实完成了工作。

0
投票
仅向模型添加字段会很有趣吗?为您的创建日期添加一个DateField。可能您需要了解更多信息:[https://docs.djangoproject.com/en/3.0/ref/models/fields/
© www.soinside.com 2019 - 2024. All rights reserved.