本文整理匯總了Python中xadmin.util.is_related_field2方法的典型用法代碼示例。如果您正苦於以下問題:Python util.is_related_field2方法的具體用法?Python util.is_related_field2怎麽用?Python util.is_related_field2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xadmin.util
的用法示例。
在下文中一共展示了util.is_related_field2方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_form_helper
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import is_related_field2 [as 別名]
def get_form_helper(self):
helper = super(RevisionView, self).get_form_helper()
diff_fields = {}
version_data = self.version.field_dict
for f in self.opts.fields:
fvalue = f.value_from_object(self.org_obj)
vvalue = version_data.get(f.name, None)
if fvalue is None and vvalue == '':
vvalue = None
if is_related_field2(f):
vvalue = version_data.get(f.name + '_' + f.rel.get_related_field().name, None)
if fvalue != vvalue:
diff_fields[f.name] = self.detail.get_field_result(f.name).val
for k, v in diff_fields.items():
helper[k].wrap(DiffField, orgdata=v)
return helper
示例2: __init__
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import is_related_field2 [as 別名]
def __init__(self, admin_view, lookup, value):
self.admin_view = admin_view
self.org_model = admin_view.model
self.opts = admin_view.opts
self.lookup = lookup
self.value = value
parts = lookup.split(LOOKUP_SEP)
field = self.opts.get_field(parts[0])
if not is_related_field2(field):
raise Exception(u'Relate Lookup field must a related field')
self.to_model = field.related_model
self.rel_name = '__'.join(parts[1:])
self.is_m2m = bool(field.many_to_many)
to_qs = self.to_model._default_manager.get_queryset()
self.to_objs = to_qs.filter(**{self.rel_name: value}).all()
self.field = field
示例3: get_form_helper
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import is_related_field2 [as 別名]
def get_form_helper(self):
helper = super(RevisionView, self).get_form_helper()
diff_fields = {}
version_data = self.version.field_dict
for f in self.opts.fields:
fvalue = f.value_from_object(self.org_obj)
vvalue = version_data.get(f.name, None)
if fvalue is None and vvalue == '':
vvalue = None
if is_related_field2(f):
vvalue = version_data.get(f.name + '_' + f.rel.get_related_field().name, None)
if fvalue != vvalue:
diff_fields[f.name] = self.detail.get_field_result(f.name).val
for k, v in diff_fields.items():
helper[k].wrap(DiffField, orgdata=v)
return helper
示例4: test
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import is_related_field2 [as 別名]
def test(cls, field, request, params, model, admin_view, field_path):
if not is_related_field2(field):
return False
related_modeladmin = admin_view.admin_site._registry.get(
get_model_from_relation(field))
return related_modeladmin and getattr(related_modeladmin, 'relfield_style', None) in ('fk-ajax', 'fk-select')