admin_forms.py 文件源码

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

项目:omni-forms 作者: omni-digital 项目源码 文件源码
def get_permitted_content_types(self):
        """
        Method for getting a queryset of permitted content types for the model form

        :return: QuerySet of ContentTYpe model instances
        """
        content_types = getattr(settings, 'OMNI_FORMS_CONTENT_TYPES', None)
        exclusions = getattr(settings, 'OMNI_FORMS_EXCLUDED_CONTENT_TYPES', [{'app_label': 'omniforms'}])
        qs = ContentType.objects.all()

        if content_types:
            query = None
            for content_type in content_types:
                kwargs = self._query_filters(content_type)
                if query is None:
                    query = Q(**kwargs)
                else:
                    query = query | Q(**kwargs)
            qs = qs.filter(query)

        elif exclusions:
            for exclusion in exclusions:
                kwargs = self._query_filters(exclusion)
                qs = qs.exclude(**kwargs)

        return qs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号