class TimeStampedModel(models.Model):
created = DateTimeField(_('created'), auto_now=False, auto_now_add=True)
modified = DateTimeField(_('modified'), auto_now=True, auto_now_add=False)
class Meta:
abstract = True
class TimeFramedModel(models.Model):
start = models.DateTimeField(_('start'), null=True, blank=True)
end = models.DateTimeField(_('end'), null=True, blank=True)
class Meta:
abstract = True
class EntryQueryset(QuerySet):
def published(self):
return self.filter(self.status == 'published')
class EntryManger(models.Manager):
def get_query_set(self):
print 'using right custom manager'
return EntryQueryset(self.model, using=self._db)
class Entry(TimeStampedModel, TimeFramedModel):
status = models.CharField(
_('status'), choices=STATUS_CHOICES, max_length=16,
default='draft')
objects = EntryManger()
当我这样做Entry.objects.published()
时,错误就会出现。它抱怨“EntryManger”对象没有“已发布”属性,
未打印“使用正确的自定义管理器”的文本。
什么可能导致此错误?谢谢!