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


Python main.IS_POPUP_VAR属性代码示例

本文整理汇总了Python中django.contrib.admin.views.main.IS_POPUP_VAR属性的典型用法代码示例。如果您正苦于以下问题:Python main.IS_POPUP_VAR属性的具体用法?Python main.IS_POPUP_VAR怎么用?Python main.IS_POPUP_VAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.contrib.admin.views.main的用法示例。


在下文中一共展示了main.IS_POPUP_VAR属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_popup_template_response_on_add

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def test_popup_template_response_on_add(self):
        """
        Success on popups shall be rendered from template in order to allow
        easy customization.
        """
        response = self.client.post(
            reverse('admin:admin_views_actor_add') + '?%s=1' % IS_POPUP_VAR,
            {'name': 'Troy McClure', 'age': '55', IS_POPUP_VAR: '1'}
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.template_name, [
            'admin/admin_views/actor/popup_response.html',
            'admin/admin_views/popup_response.html',
            'admin/popup_response.html',
        ])
        self.assertTemplateUsed(response, 'admin/popup_response.html') 
开发者ID:nesdis,项目名称:djongo,代码行数:18,代码来源:test_actions.py

示例2: render

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def render(self, name, value, *args, **kwargs):
        from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
        rel_opts = self.rel.to._meta
        info = (rel_opts.app_label, rel_opts.model_name)
        self.widget.choices = self.choices
        url_params = '&'.join("%s=%s" % param for param in [
            (TO_FIELD_VAR, self.rel.get_related_field().name),
            (IS_POPUP_VAR, 1),
        ])
        context = {
            'widget': self.widget.render(name, value, *args, **kwargs),
            'name': name,
            'url_params': url_params,
            'model': rel_opts.verbose_name,
        }
        if self.can_change_related:
            change_related_template_url = self.get_related_url(info, 'change', '__fk__')
            context.update(
                can_change_related=True,
                change_related_template_url=change_related_template_url,
            )
        if self.can_add_related:
            add_related_url = self.get_related_url(info, 'add')
            context.update(
                can_add_related=True,
                add_related_url=add_related_url,
            )
        if self.can_delete_related:
            delete_related_template_url = self.get_related_url(info, 'delete', '__fk__')
            context.update(
                can_delete_related=True,
                delete_related_template_url=delete_related_template_url,
            )
        return mark_safe(render_to_string(self.template, context)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:36,代码来源:widgets.py

示例3: get_context

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def get_context(self, name, value, attrs):
        from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
        rel_opts = self.rel.model._meta
        info = (rel_opts.app_label, rel_opts.model_name)
        self.widget.choices = self.choices
        url_params = '&'.join("%s=%s" % param for param in [
            (TO_FIELD_VAR, self.rel.get_related_field().name),
            (IS_POPUP_VAR, 1),
        ])
        context = {
            'rendered_widget': self.widget.render(name, value, attrs),
            'name': name,
            'url_params': url_params,
            'model': rel_opts.verbose_name,
        }
        if self.can_change_related:
            change_related_template_url = self.get_related_url(info, 'change', '__fk__')
            context.update(
                can_change_related=True,
                change_related_template_url=change_related_template_url,
            )
        if self.can_add_related:
            add_related_url = self.get_related_url(info, 'add')
            context.update(
                can_add_related=True,
                add_related_url=add_related_url,
            )
        if self.can_delete_related:
            delete_related_template_url = self.get_related_url(info, 'delete', '__fk__')
            context.update(
                can_delete_related=True,
                delete_related_template_url=delete_related_template_url,
            )
        return context 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:36,代码来源:widgets.py

示例4: render

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def render(self, name, value, *args, **kwargs):
        self.widget.choices = self.choices

        url_params = "%s=%s" % (IS_POPUP_VAR, 1)
        context = {
            'widget': self.widget.render(name, value, *args, **kwargs),
            'name': name,
            'url_params': url_params,
            'add_related_url': self.add_related_url,
            'add_icon': self.add_icon,
            'edit_related_url': self.edit_related_url,
            'edit_icon': self.edit_icon,
        }
        return mark_safe(render_to_string(self.template, context)) 
开发者ID:jonashaag,项目名称:django-addanother,代码行数:16,代码来源:widgets.py

示例5: get_context

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def get_context(self, name, value, attrs):
        from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
        rel_opts = self.rel.model._meta
        info = (rel_opts.app_label, rel_opts.model_name)
        self.widget.choices = self.choices
        url_params = '&'.join("%s=%s" % param for param in [
            (TO_FIELD_VAR, self.rel.get_related_field().name),
            (IS_POPUP_VAR, 1),
        ])
        context = {
            'rendered_widget': self.widget.render(name, value, attrs),
            'name': name,
            'url_params': url_params,
            'model': rel_opts.verbose_name,
            'can_add_related': self.can_add_related,
            'can_change_related': self.can_change_related,
            'can_delete_related': self.can_delete_related,
            'can_view_related': self.can_view_related,
        }
        if self.can_add_related:
            context['add_related_url'] = self.get_related_url(info, 'add')
        if self.can_delete_related:
            context['delete_related_template_url'] = self.get_related_url(info, 'delete', '__fk__')
        if self.can_view_related or self.can_change_related:
            context['change_related_template_url'] = self.get_related_url(info, 'change', '__fk__')
        return context 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:28,代码来源:widgets.py

示例6: render

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def render(self, name, value, *args, **kwargs):
        from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
        rel_opts = self.rel.model._meta
        info = (rel_opts.app_label, rel_opts.model_name)
        self.widget.choices = self.choices
        url_params = '&'.join("%s=%s" % param for param in [
            (TO_FIELD_VAR, self.rel.get_related_field().name),
            (IS_POPUP_VAR, 1),
        ])
        context = {
            'widget': self.widget.render(name, value, *args, **kwargs),
            'name': name,
            'url_params': url_params,
            'model': rel_opts.verbose_name,
        }
        if self.can_change_related:
            change_related_template_url = self.get_related_url(info, 'change', '__fk__')
            context.update(
                can_change_related=True,
                change_related_template_url=change_related_template_url,
            )
        if self.can_add_related:
            add_related_url = self.get_related_url(info, 'add')
            context.update(
                can_add_related=True,
                add_related_url=add_related_url,
            )
        if self.can_delete_related:
            delete_related_template_url = self.get_related_url(info, 'delete', '__fk__')
            context.update(
                can_delete_related=True,
                delete_related_template_url=delete_related_template_url,
            )
        return mark_safe(render_to_string(self.template, context)) 
开发者ID:drexly,项目名称:openhgsenti,代码行数:36,代码来源:widgets.py

示例7: test_popup_actions

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def test_popup_actions(self):
        """ Actions aren't shown in popups."""
        changelist_url = reverse('admin:admin_views_subscriber_changelist')
        response = self.client.get(changelist_url)
        self.assertIsNotNone(response.context['action_form'])
        response = self.client.get(changelist_url + '?%s' % IS_POPUP_VAR)
        self.assertIsNone(response.context['action_form']) 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_actions.py

示例8: test_popup_template_response_on_change

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def test_popup_template_response_on_change(self):
        instance = Actor.objects.create(name='David Tennant', age=45)
        response = self.client.post(
            reverse('admin:admin_views_actor_change', args=(instance.pk,)) + '?%s=1' % IS_POPUP_VAR,
            {'name': 'David Tennant', 'age': '46', IS_POPUP_VAR: '1'}
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.template_name, [
            'admin/admin_views/actor/popup_response.html',
            'admin/admin_views/popup_response.html',
            'admin/popup_response.html',
        ])
        self.assertTemplateUsed(response, 'admin/popup_response.html') 
开发者ID:nesdis,项目名称:djongo,代码行数:15,代码来源:test_actions.py

示例9: test_popup_template_response_on_delete

# 需要导入模块: from django.contrib.admin.views import main [as 别名]
# 或者: from django.contrib.admin.views.main import IS_POPUP_VAR [as 别名]
def test_popup_template_response_on_delete(self):
        instance = Actor.objects.create(name='David Tennant', age=45)
        response = self.client.post(
            reverse('admin:admin_views_actor_delete', args=(instance.pk,)) + '?%s=1' % IS_POPUP_VAR,
            {IS_POPUP_VAR: '1'}
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.template_name, [
            'admin/admin_views/actor/popup_response.html',
            'admin/admin_views/popup_response.html',
            'admin/popup_response.html',
        ])
        self.assertTemplateUsed(response, 'admin/popup_response.html') 
开发者ID:nesdis,项目名称:djongo,代码行数:15,代码来源:test_actions.py


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