get_queryset在模型管理器中不起作用
class ProductManager(models.Model):
def featured(self):
return self.get_queryset().filter(featured=True)
我正在尝试使用晚餐类解决此问题。但是不行
return super(ProductManager, self).get_queryset().filter(featured=True)
class Product(models.Model):
title = models.CharField(max_length=120)
price = models.DecimalField(max_digits=20, decimal_places=2)
description = models.TextField(null=True, blank=True)
image = models.ImageField(upload_to=upload_image_path, null=True, blank=True)
featured = models.BooleanField(default=False)
objects = ProductManager()
AttributeError:“经理”对象没有“功能”属性
class ProductListFeaturedView(ListView):
# model = Product
template_name = 'products/list.html'
def get_queryset(self):
return Product.objects.featured()
我第一次遇到这个问题。