如何将参数传递给django模型管理器的get_queryset方法?

时间:2014-06-12 10:36:13

标签: django django-models django-managers

我正在尝试遵循此documentation。我想以某种方式将参数传递给get_query_set,但不知道如何。下面没有工作演示。

class ContextAwareNotificationsManager(models.Manager):

    def get_query_set(self, user):
        return super(ContextAwareNotificationsManager, self).get_query_set(user).filter((
            Q(kind='SYSTEM') | Q(kind='TODO', status=False)
        ), content_type__name__in=['publisher', 'site', 'channel']).order_by('-date')

1 个答案:

答案 0 :(得分:2)

这应该是你要找的东西:

class ContextAwareNotificationsManager(models.Manager):

    def filter_user(self, user):
        return super(ContextAwareNotificationsManager, self).get_query_set().filter(...)
相关问题