本文整理汇总了Python中django.contrib.admin.ModelAdmin.change_view方法的典型用法代码示例。如果您正苦于以下问题:Python ModelAdmin.change_view方法的具体用法?Python ModelAdmin.change_view怎么用?Python ModelAdmin.change_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.ModelAdmin
的用法示例。
在下文中一共展示了ModelAdmin.change_view方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: except
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import change_view [as 别名]
option_type = obj.option_type
except (self.model.DoesNotExist, ValueError), e:
option_type = None
if extra_context is None:
extra_context = {}
extra_context['app_label'] = _("GDT Nav")
extra_context['menu_option_types'] = MenuOption.MODEL_TYPE_CHOICES
if option_type is not None:
option_type = int(option_type)
extra_context['crumb'] = obj.name
admin_class = self.fetch_admin_class(option_type)
admin_instance = admin_class(MenuOption, self.admin_site)
return admin_instance.change_view(request, object_id, extra_context)
else:
extra_context['default_form'] = True
return ModelAdmin.change_view(self, request, object_id, extra_context)
def changelist_view(self, request, extra_context=None):
if extra_context is None:
extra_context = {}
extra_context['menu_option_types'] = MenuOption.MODEL_TYPE_CHOICES
extra_context['app_label'] = _("GDT Nav")
extra_context['menu_groups'] = MenuGroup.objects.order_by('name')
return ModelAdmin.changelist_view(self, request, extra_context)
def get_urls(self):
from django.conf.urls.defaults import patterns, url
urlpatterns = ModelAdmin.get_urls(self)
def wrap(view):
def wrapper(*args, **kwargs):
return self.admin_site.admin_view(view)(*args, **kwargs)
示例2: change_view
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import change_view [as 别名]
def change_view(self, request, object_id, form_url='', extra_context=None):
return ModelAdmin.change_view(self, request, object_id, form_url=form_url, extra_context={
'prices': Price.objects.all().values(),
'payment_methods': PaymentMethod.objects.all().values()
})