如何继承 ModelManager?
class Content(models.Model):
name = models.CharField(max_length=255, verbose_name='Name des Blogs')
slug = models.SlugField(max_length=80, blank=True)
objects = models.Manager()
active = ContentActiveManager()
class ContentActiveManager(models.Manager):
def get_query_set(self):
return super(ContentActiveManager,self).get_query_set().filter(activated=True,show=True)
class BlogCatalog(Content):
frequency = models.PositiveSmallIntegerField(max_length=2, choices=make_index_based_tuple(l=FREQUENCY), verbose_name='Frequenz',)
blog = BlogCatalog.active.get(pk=1)
blog
现在显然是一个Content对象。
如果我输入Catalog.active.get(pk=1),我想要一个Content对象,
但是如果我输入BlogCatalog.active.get(pk=1),我想要一个BlogCatalog对象。
如何避免冗余地实现这一点?