multiform.py 文件源码

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

项目:a4-opin 作者: liqd 项目源码 文件源码
def _combine(self, *args, **kwargs):
        """
        Combine with filter argument doesn't work for form sets. Because
        formsets will return always a list of values and even lists of falsy
        values are truthy.

        This extends combine to inside the lists returned by the formset and
        filter it if all values inside are false.

        WARNING: This kind of hacky. It should be better fixed somewhere else.
        """
        base_forms = self.get_base_forms()
        values = super()._combine(*args, **kwargs)
        if 'filter' in kwargs and kwargs['filter']:
            values = OrderedDict([
                (name, value) for name, value in values.items()
                if not issubclass(base_forms[name], formsets.BaseFormSet)
                or any(value)
            ])
        return values
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号