本文整理匯總了Python中django.contrib.auth.admin.UserAdmin方法的典型用法代碼示例。如果您正苦於以下問題:Python admin.UserAdmin方法的具體用法?Python admin.UserAdmin怎麽用?Python admin.UserAdmin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.auth.admin
的用法示例。
在下文中一共展示了admin.UserAdmin方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_check_custom_user_model_default_admin
# 需要導入模塊: from django.contrib.auth import admin [as 別名]
# 或者: from django.contrib.auth.admin import UserAdmin [as 別名]
def test_check_custom_user_model_default_admin(self):
# Django doesn't re-register admins when using `override_settings`,
# so we have to do it manually in this test case.
admin.site.register(get_user_model(), UserAdmin)
warnings = checks.check_custom_user_model(HijackAdminConfig)
expected_warnings = [
Warning(
'django-hijack-admin does not work out the box with a custom user model.',
hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
obj=settings.AUTH_USER_MODEL,
id='hijack_admin.W001',
)
]
self.assertEqual(warnings, expected_warnings)
admin.site.unregister(get_user_model())
示例2: test_submit_row
# 需要導入模塊: from django.contrib.auth import admin [as 別名]
# 或者: from django.contrib.auth.admin import UserAdmin [as 別名]
def test_submit_row(self):
"""
submit_row template tag should pass whole context.
"""
factory = RequestFactory()
request = factory.get(reverse('admin:auth_user_change', args=[self.superuser.pk]))
request.user = self.superuser
admin = UserAdmin(User, site)
extra_context = {'extra': True}
response = admin.change_view(request, str(self.superuser.pk), extra_context=extra_context)
template_context = submit_row(response.context_data)
self.assertIs(template_context['extra'], True)
self.assertIs(template_context['show_save'], True)
示例3: test_submit_row
# 需要導入模塊: from django.contrib.auth import admin [as 別名]
# 或者: from django.contrib.auth.admin import UserAdmin [as 別名]
def test_submit_row(self):
"""
submit_row template tag should pass whole context.
"""
request = self.request_factory.get(reverse('admin:auth_user_change', args=[self.superuser.pk]))
request.user = self.superuser
admin = UserAdmin(User, site)
extra_context = {'extra': True}
response = admin.change_view(request, str(self.superuser.pk), extra_context=extra_context)
template_context = submit_row(response.context_data)
self.assertIs(template_context['extra'], True)
self.assertIs(template_context['show_save'], True)