django - django部分搜索问题
问题描述
这个需要搜索的示例文本
状态模型
{
"region": "National Capital Territory of Delhi",
"country": "in"
},
{
"region": "Union Territory of Chandigarh",
"country": "in"
},
我在服务器上有两个模型,第一个是国家模型,用户在其中选择他们居住的国家,然后从该状态过滤并显示。
所以现在如果他们Chandigarh
在使用时输入他们查询
state = loginModels.State.objects.filter(country=country_code.lower()).filter(region__icontains=state).get()
它会自动选择->Union Territory of Chandigarh
但,
现在,如果用户键入NCT of Delhi
上述查询失败,我也尝试Q
了博客中建议的方法,这也失败了。
state = loginModels.State.objects.filter(country=country_code.lower()).filter(Q(region__icontains=query)).get()
PS
注意在这个用户代表系统,所以后端系统调用NCT
和上面的查询在几个我们不想硬编码的地方失败。
任何形式的帮助将不胜感激。
解决方案
推荐阅读
- javascript - 节点服务器在 Windows 10 中启动服务器花费了太多时间
- r - R 闪亮的反应单选按钮
- powerapps - 缺少使用 Sql 的默认电源应用程序的添加、编辑和删除功能
- javascript - 如何从 JSON fromat 中提取特定字段和值
- ubuntu - shell脚本中的monit命令
- performance - 针对特定设备的唯一 ID 的移动性能测试,这里我没有用户凭据,如何进行用户负载测试?
- gitahead - GitAhead 禁用 HTTPS 登录窗口
- c++ - ofstream不输出文件
- python - 在远程数据库服务器设置上实现 PostgreSQL 的性能
- testing - 是否可以使用 CANalyzer 将错误帧传输到总线上?