當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。