本文整理汇总了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)