我无法让我的自定义管理器工作...
class PublicArtigoManager(models.Manager):
def get_queryset(self):
return super(PublicArtigoManager, self).get_queryset().filter(data_publicacao__lte=timezone.now()).filter(permissao__lte=3)
class Artigo(models.Model):
...
objects = models.Manager()
publics = PublicArtigoManager()
当我在 shell 中测试时,它不起作用
>>> from artigos.models import Artigo
>>> from django.utils import timezone
>>> print Artigo.objects.count()
9960
>>> print Artigo.publics.count()
9960
>>> print Artigo.objects.filter(data_publicacao__lte=timezone.now()).filter(permissao__lte=3).count()
9959
Artigo.publics.count()
应该返回 9959,对吗?有什么想法可能会出错吗?