当前位置: 首页>>代码示例>>Python>>正文


Python admin.UserAdmin方法代码示例

本文整理汇总了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()) 
开发者ID:arteria,项目名称:django-hijack-admin,代码行数:19,代码来源:test_checks.py

示例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) 
开发者ID:nesdis,项目名称:djongo,代码行数:15,代码来源:test_templatetags.py

示例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) 
开发者ID:nesdis,项目名称:djongo,代码行数:14,代码来源:test_templatetags.py


注:本文中的django.contrib.auth.admin.UserAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。