django-filter - 向 ModelChoiceFilter 添加 None 选项
问题描述
我的过滤器运行良好,但我希望选择“无”来查找商家组==无的交易。我在文档中找不到这个选项,这不可能吗?
class TransactionFilter(django_filters.FilterSet):
merchant_group = django_filters.ModelChoiceFilter(field_name='merchant__merchant_group', empty_label="Merchant", queryset=MerchantGroup.objects.all().order_by('name'))
解决方案
推荐阅读
- c# - 由于引用导致不需要的成员更改
- python - 错误:试图将形状不兼容的张量附加到列表中
- http - 如何在 dart http 请求中添加 jsessionid cookie
- android - 无法从 https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml 加载 Maven 元数据反应原生问题
- sql - postgres中的外键约束
- javascript - 在 JavaScript“未定义”对象中读取 JSON 文件
- pine-script - Pine Script - 金字塔内入场价格的计算
- pyarmor - pyarmor:如何在虚拟环境中混淆 site_package
- regex - Postgresql - 正则表达式获取字符串中没有特殊字符的所有单词,除了 -
- google-apps-script - 如何在 Google Apps 脚本上合并具有相同列值的行