python类ForeignObjectRel()的实例源码

util.py 文件源码 项目:Charlotte 作者: LiZoRN 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_related_field(field):
    return isinstance(field, ForeignObjectRel)
util.py 文件源码 项目:imooc-django 作者: zaxlct 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_related_field(field):
    return isinstance(field, ForeignObjectRel)
util.py 文件源码 项目:muxueonline 作者: 124608760 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def is_related_field(field):
    return isinstance(field, ForeignObjectRel)
filters.py 文件源码 项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def has_output(self):
        if (isinstance(self.field, ForeignObjectRel) and
                self.field.field.null or hasattr(self.field, 'rel') and
                self.field.null):
            extra = 1
        else:
            extra = 0
        return len(self.lookup_choices) + extra > 1
filters.py 文件源码 项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def choices(self, cl):
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
        yield {
            'selected': self.lookup_val is None and not self.lookup_val_isnull,
            'query_string': cl.get_query_string({},
                [self.lookup_kwarg, self.lookup_kwarg_isnull]),
            'display': _('All'),
        }
        for pk_val, val in self.lookup_choices:
            yield {
                'selected': self.lookup_val == smart_text(pk_val),
                'query_string': cl.get_query_string({
                    self.lookup_kwarg: pk_val,
                }, [self.lookup_kwarg_isnull]),
                'display': val,
            }
        if (isinstance(self.field, ForeignObjectRel) and
                (self.field.field.null or isinstance(self.field.field, ManyToManyField)) or
                hasattr(self.field, 'rel') and (self.field.null or isinstance(self.field, ManyToManyField))):
            yield {
                'selected': bool(self.lookup_val_isnull),
                'query_string': cl.get_query_string({
                    self.lookup_kwarg_isnull: 'True',
                }, [self.lookup_kwarg]),
                'display': EMPTY_CHANGELIST_VALUE,
            }


问题


面经


文章

微信
公众号

扫码关注公众号