当前位置: 首页>>代码示例>>Python>>正文


Python util.label_for_field方法代码示例

本文整理汇总了Python中xadmin.util.label_for_field方法的典型用法代码示例。如果您正苦于以下问题:Python util.label_for_field方法的具体用法?Python util.label_for_field怎么用?Python util.label_for_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xadmin.util的用法示例。


在下文中一共展示了util.label_for_field方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: result_item

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def result_item(self, item, obj, field_name, row):
        if self.list_editable and item.field and item.field.editable and (field_name in self.list_editable):            
            pk = getattr(obj, obj._meta.pk.attname)
            field_label = label_for_field(field_name, obj,
                                          model_admin=self.admin_view,
                                          return_attr=False
                                          )

            item.wraps.insert(0, '<span class="editable-field">%s</span>')
            item.btns.append((
                '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">' +
                '<i class="fa fa-edit"></i></a>') %
                (_(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url('patch', pk) + '?fields=' + field_name))

            if field_name not in self.editable_need_fields:
                self.editable_need_fields[field_name] = item.field
        return item

    # Media 
开发者ID:stormsha,项目名称:StormOnline,代码行数:21,代码来源:editable.py

示例2: result_item

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def result_item(self, item, obj, field_name, row):
        if self._current_layout == 'thumbnails':
            if getattr(item.attr, 'is_column', True):
                item.field_label = label_for_field(
                    field_name, self.model,
                    model_admin=self.admin_view,
                    return_attr=False
                )
            if getattr(item.attr, 'thumbnail_img', False):
                setattr(item, 'thumbnail_hidden', True)
                row['thumbnail_img'] = item
            elif item.is_display_link:
                setattr(item, 'thumbnail_hidden', True)
                row['thumbnail_label'] = item

        return item

    # Block Views 
开发者ID:stormsha,项目名称:StormOnline,代码行数:20,代码来源:layout.py

示例3: result_item

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def result_item(self, item, obj, field_name, row):
        if self.list_editable and item.field and item.field.editable and (field_name in self.list_editable):
            pk = getattr(obj, obj._meta.pk.attname)
            field_label = label_for_field(field_name, obj,
                                          model_admin=self.admin_view,
                                          return_attr=False
                                          )

            item.wraps.insert(0, '<span class="editable-field">%s</span>')
            item.btns.append((
                '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">' +
                '<i class="fa fa-edit"></i></a>') %
                (_(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url('patch', pk) + '?fields=' + field_name))

            if field_name not in self.editable_need_fields:
                self.editable_need_fields[field_name] = item.field
        return item

    # Media 
开发者ID:Superbsco,项目名称:weibo-analysis-system,代码行数:21,代码来源:editable.py

示例4: init

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def init(self):
        self.label = label_for_field(self.field_name, self.obj.__class__,
                                     model_admin=self.admin_view,
                                     return_attr=False
                                     )
        try:
            f, attr, value = lookup_field(
                self.field_name, self.obj, self.admin_view)
        except (AttributeError, ObjectDoesNotExist):
            self.text
        else:
            if f is None:
                self.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    self.allow_tags = True
                    self.text = boolean_icon(value)
                else:
                    self.text = smart_text(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    self.text = getattr(self.obj, f.name)
                else:
                    self.text = display_for_field(value, f)
            self.field = f
            self.attr = attr
            self.value = value 
开发者ID:stormsha,项目名称:StormOnline,代码行数:29,代码来源:detail.py

示例5: init

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def init(self):
        self.label = label_for_field(self.field_name, self.obj.__class__,
                                     model_admin=self.admin_view,
                                     return_attr=False
                                     )
        try:
            f, attr, value = lookup_field(
                self.field_name, self.obj, self.admin_view)
        except (AttributeError, ObjectDoesNotExist):
            self.text
        else:
            if f is None:
                self.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    self.allow_tags = True
                    self.text = boolean_icon(value)
                else:
                    self.text = smart_text(value)
            else:
                if isinstance(f.remote_field, models.ManyToOneRel):
                    self.text = getattr(self.obj, f.name)
                else:
                    self.text = display_for_field(value, f)
            self.field = f
            self.attr = attr
            self.value = value 
开发者ID:Superbsco,项目名称:weibo-analysis-system,代码行数:29,代码来源:detail.py

示例6: init

# 需要导入模块: from xadmin import util [as 别名]
# 或者: from xadmin.util import label_for_field [as 别名]
def init(self):
        self.label = label_for_field(self.field_name, self.obj.__class__,
                                     model_admin=self.admin_view,
                                     return_attr=False
                                     )
        try:
            f, attr, value = lookup_field(
                self.field_name, self.obj, self.admin_view)
        except (AttributeError, ObjectDoesNotExist):
            self.text
        else:
            if f is None:
                self.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    self.allow_tags = True
                    self.text = boolean_icon(value)
                else:
                    self.text = smart_unicode(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    self.text = getattr(self.obj, f.name)
                else:
                    self.text = display_for_field(value, f)
            self.field = f
            self.attr = attr
            self.value = value 
开发者ID:madre,项目名称:devops,代码行数:29,代码来源:detail.py


注:本文中的xadmin.util.label_for_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。