views.py 文件源码

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

项目:WikiLinks 作者: JakobGM 项目源码 文件源码
def get_queryset(self):
        """
        Returns a queryset used for autocompletion, restricted based
        on the user input.
        """
        # Only let logged in users access all the course information
        if not self.request.user.is_authenticated():
            return Course.objects.none()

        qs = Course.objects.all()

        # If the user has started entering input, start restricting
        # the choices available for autocompletion.
        if self.q:
            course_code = Q(course_code__istartswith=self.q)
            full_name = Q(full_name__istartswith=self.q)
            display_name = Q(display_name__startswith=self.q)
            qs = qs.filter(course_code | full_name | display_name)

        return qs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号