使用和条件Django筛选具有多个值的同一列
sql查询如下所示使用和条件Django筛选具有多个值的同一列,django,django-models,django-queryset,Django,Django Models,Django Queryset,sql查询如下所示 从Catalog\u ProductCatalog中选择*,其中(Catalog\u id=40)和(product\u id=7)实际上我找到了解决方案。 pc=ProductCategory.objects.filter(Q(category\u id=40)和Q(category\u id=44))您为它们定义了模型类吗 class catalogue_productcategory(model.Model): #define your desire field
从Catalog\u ProductCatalog中选择*,其中(Catalog\u id=40)和(product\u id=7)实际上我找到了解决方案。
pc=ProductCategory.objects.filter(Q(category\u id=40)和Q(category\u id=44))您为它们定义了模型类吗
class catalogue_productcategory(model.Model):
#define your desire fields
category = model.ForeignKey(Category)
product = model.ForeignKey(Product)
catalogue_productcategory.objects.filter(category__id=40, product__id=7)