无法通过外键过滤记录中的错误

时间:2013-12-05 07:41:45

标签: python django django-models models

我目前在以下查询中遇到错误。

projects.objects.all()

这是我的代码:

Models.py

class ProjectManager(models.Manager):
"""A re-usable Manager to access a custom QuerySet"""

def __getattr__(self, attr, *args):
    try:
        return getattr(self.__class__, attr, *args)
    except AttributeError:
        return getattr(self.get_query_set(), attr, *args)

def get_query_set(self):
    return self.model.QuerySet(self.model)


class Project(models.Model):
objects = ProjectManager()

class QuerySet(QuerySet):
    def add_priority(self):
        return self.extra(select={"priority": "COALESCE(bm_rank, sales_rank, id)"}, order_by=["priority"])
        # return self.filter(*args, **kwargs)

    def add_size(self):
        return self.extra(select={"size": "order_size_price*order_size_weight"})

Views.py

new_requests = projects.objects.all()

我不确定为什么会出现这个错误,请帮忙

0 个答案:

没有答案