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