reports.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:django-admin-reports 作者: simplyopen-it 项目源码 文件源码
def _items(self, record):
        for field_name, _ in self.get_fields():
            # Does the field_name refer to an aggregation column or is
            # it an attribute of this instance?
            try:
                attr_field = getattr(self, field_name)
            except AttributeError:
                # The field is a record element
                ret = record.get(field_name)
                formatting_func = self.get_formatting().get(field_name)
                if formatting_func is not None:
                    try:
                        ret = formatting_func(ret)
                    except (TypeError, ValueError):
                        pass
            else:
                # The view class has an attribute with this field_name
                if callable(attr_field):
                    ret = attr_field(record)
                    if getattr(attr_field, 'allow_tags', False):
                        ret = mark_safe(ret)
            yield ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号