我尝试在我的模型中使用django_filters
withJSONfield,但我不能这样做。在
如果使用CharFields
我可以得到当前的结果,但我需要对请求进行可能的工作。
当我使用ModelMultipleChoiceFilter
时,我从filter中得到了所有的变体,但是过滤并没有发生。在
Models.py
class Product(models.Model):
name = models.CharField(max_length=120)
properties = JSONField(default=dict, blank=True, null=True, db_index=True)
Filters.py
This is Item
{
"id": 10,
"name": "Test_3",
"properties": {
"color": "Black",
"invertor technology": false,
"service area, m²": 24
},
},
选择黑色,
我有一个错误:选择正确的选项。黑色在值中无效。
结果非常简单,只需使用
AllValuesMultipleFilter
非常感谢rpkilby。 链接此issue。在
相关问题 更多 >
编程相关推荐