本文整理匯總了Python中xadmin.widgets.AdminSelectWidget方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.AdminSelectWidget方法的具體用法?Python widgets.AdminSelectWidget怎麽用?Python widgets.AdminSelectWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xadmin.widgets
的用法示例。
在下文中一共展示了widgets.AdminSelectWidget方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_field_attrs
# 需要導入模塊: from xadmin import widgets [as 別名]
# 或者: from xadmin.widgets import AdminSelectWidget [as 別名]
def get_field_attrs(self, db_field, **kwargs):
if db_field.name in self.style_fields:
attrs = self.get_field_style(
db_field, self.style_fields[db_field.name], **kwargs)
if attrs:
return attrs
if hasattr(db_field, "rel") and db_field.rel:
related_modeladmin = self.admin_site._registry.get(db_field.rel.to)
if related_modeladmin and hasattr(related_modeladmin, 'relfield_style'):
attrs = self.get_field_style(
db_field, related_modeladmin.relfield_style, **kwargs)
if attrs:
return attrs
if db_field.choices:
return {'widget': widgets.AdminSelectWidget}
for klass in db_field.__class__.mro():
if klass in self.formfield_overrides:
return self.formfield_overrides[klass].copy()
return {}