Python语法错误在哪里?

2024-06-16 05:52:12 发布

您现在位置:Python中文网/ 问答频道 /正文

回到Python,在0.9.xpinax安装中至少有一个语法错误。我在这里尝试的是添加一个额外的过滤层(在默认的可选过滤层之上,该过滤层提供了允许用户查看所有博客条目或某个特定用户的所有博客条目的功能)。你知道吗

在另一个文件中,自定义.py,我有一个函数threshold_check(),用于以另一种方式进行过滤;它接受两个参数,一个Django用户和包括博客文章在内的多种对象类型中的一个,并返回true或false,以确定是否应该包含该项。你知道吗

我的代码看起来是正确的,但是Django在列表的第二行报告了一个语法错误,将allowed_blogs填充到:

def blogs(request, username=None, template_name="blog/blogs.html"):
    blogs = Post.objects.filter(status=2).select_related(depth=1).order_by("-publish")
    if username is not None:
        user = get_object_or_404(User, username=username.lower())
        blogs = blogs.filter(author=user)
    allowed_blogs = [blog in blogs.objects.all() if
      custom.threshold_check(request.user, blog)]
    return render_to_response(template_name, {
        "blogs": allowed_blogs,
    }, context_instance=RequestContext(request))

我做错了什么?我需要做什么才能允许引用的custom.threshold_check()批准或否决包含在allowed_blogs列表中的Pinax博客对象?你知道吗

蒂亚


Tags: 对象django用户none列表thresholdrequestcheck