本文整理汇总了Python中social.apps.django_app.default.models.UserSocialAuth.user_model方法的典型用法代码示例。如果您正苦于以下问题:Python UserSocialAuth.user_model方法的具体用法?Python UserSocialAuth.user_model怎么用?Python UserSocialAuth.user_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类social.apps.django_app.default.models.UserSocialAuth
的用法示例。
在下文中一共展示了UserSocialAuth.user_model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_search_fields
# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import user_model [as 别名]
def get_search_fields(self):
search_fields = getattr(
settings, setting_name('ADMIN_USER_SEARCH_FIELDS'), None
)
if search_fields is None:
_User = UserSocialAuth.user_model()
username = getattr(_User, 'USERNAME_FIELD', None) or \
hasattr(_User, 'username') and 'username' or \
None
fieldnames = ('first_name', 'last_name', 'email', username)
all_names = _User._meta.get_all_field_names()
search_fields = [name for name in fieldnames
if name and name in all_names]
return ['user_' + name for name in search_fields]
示例2: UserSocialAuthOption
# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import user_model [as 别名]
"""Admin settings"""
from django.contrib import admin
from social.apps.django_app.default.models import UserSocialAuth, Nonce, \
Association
_User = UserSocialAuth.user_model()
username = getattr(_User, 'USERNAME_FIELD', None) or \
hasattr(_User, 'username') and 'username' or \
None
fieldnames = ('first_name', 'last_name', 'email', username)
all_names = _User._meta.get_all_field_names()
user_search_fields = ['user__' + name for name in fieldnames
if name and name in all_names]
class UserSocialAuthOption(admin.ModelAdmin):
"""Social Auth user options"""
list_display = ('id', 'user', 'provider', 'uid')
search_fields = user_search_fields
list_filter = ('provider',)
raw_id_fields = ('user',)
list_select_related = True
class NonceOption(admin.ModelAdmin):
"""Nonce options"""
list_display = ('id', 'server_url', 'timestamp', 'salt')
search_fields = ('server_url',)