如何将Django过滤器结果分配给Django中的verbose_name_plural变量#?
研究了如何在Django中使用用户输入并在python中访问类变量来构造动态查询
inventory = InventoriFilter()
obj = {
"inventory":[inventory.inventori],
}
inventoris = Inventory.objects.filter(*obj['inventory'])
context={
'inventoris': inventoris,
}
class InventoriFilter(django_filters.FilterSet):
inventori = django_filters.CharFilter(lookup_expr='icontains')
class Meta:
model = Inventory
fields = ['id', 'inventori', 'price', 'quantity',]
class Inventori(models.Model):
inventori = models.CharField(max_length=50)