本文整理匯總了Python中wagtail.admin.edit_handlers.ObjectList.bind_to_model方法的典型用法代碼示例。如果您正苦於以下問題:Python ObjectList.bind_to_model方法的具體用法?Python ObjectList.bind_to_model怎麽用?Python ObjectList.bind_to_model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wagtail.admin.edit_handlers.ObjectList
的用法示例。
在下文中一共展示了ObjectList.bind_to_model方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_edit_handler
# 需要導入模塊: from wagtail.admin.edit_handlers import ObjectList [as 別名]
# 或者: from wagtail.admin.edit_handlers.ObjectList import bind_to_model [as 別名]
def get_edit_handler(self):
if hasattr(self.model, 'edit_handler'):
edit_handler = self.model.edit_handler
else:
fields_to_exclude = self.model_admin.get_form_fields_exclude(request=self.request)
panels = extract_panel_definitions_from_model_class(self.model, exclude=fields_to_exclude)
edit_handler = ObjectList(panels)
return edit_handler.bind_to_model(self.model)
示例2: get_snippet_edit_handler
# 需要導入模塊: from wagtail.admin.edit_handlers import ObjectList [as 別名]
# 或者: from wagtail.admin.edit_handlers.ObjectList import bind_to_model [as 別名]
def get_snippet_edit_handler(model):
if model not in SNIPPET_EDIT_HANDLERS:
if hasattr(model, 'edit_handler'):
# use the edit handler specified on the page class
edit_handler = model.edit_handler
else:
panels = extract_panel_definitions_from_model_class(model)
edit_handler = ObjectList(panels)
SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to_model(model)
return SNIPPET_EDIT_HANDLERS[model]
示例3: get_edit_handler
# 需要導入模塊: from wagtail.admin.edit_handlers import ObjectList [as 別名]
# 或者: from wagtail.admin.edit_handlers.ObjectList import bind_to_model [as 別名]
def get_edit_handler(self):
if hasattr(self.model, 'edit_handler'):
edit_handler = self.model.edit_handler
elif hasattr(self.model, 'panels'):
edit_handler = ObjectList(self.model.panels)
else:
edit_handler = TabbedInterface([
ObjectList(self.model.content_panels, heading=_("Content")),
ObjectList(self.model.settings_panels, heading=_("Settings"),
classname="settings"),
])
return edit_handler.bind_to_model(self.model)
示例4: _patch_other_models
# 需要導入模塊: from wagtail.admin.edit_handlers import ObjectList [as 別名]
# 或者: from wagtail.admin.edit_handlers.ObjectList import bind_to_model [as 別名]
def _patch_other_models(self, model):
if hasattr(model, 'edit_handler'):
edit_handler = model.edit_handler
for tab in edit_handler:
tab.children = self._patch_panels(tab.children)
elif hasattr(model, 'panels'):
model.panels = self._patch_panels(model.panels)
else:
panels = extract_panel_definitions_from_model_class(model)
translation_registered_fields = translator.get_options_for_model(model).fields
panels = filter(lambda field: field.field_name not in translation_registered_fields, panels)
edit_handler = ObjectList(panels)
SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to_model(model)