Django框架 之 查询 Extra的where里如何写like前/后置匹配逻辑

查询Extra的where里写like后置匹配关键词逻辑,代码示例:
    sqlWhere = ['name like %s']  
    sqlParam = ['%' +keyword]
    markets = WFmarket.objects.extra(where=sqlWhere, params=sqlParam)
查询Extra的where里写like前置匹配关键词逻辑,代码示例:
    sqlWhere = ['name like %s']  
    sqlParam = [keyword + '%' ]
    markets = WFmarket.objects.extra(where=sqlWhere, params=sqlParam)
查询Filter的字段包含关键词匹配逻辑(不匹配大小写字母敏感),代码示例:
    markets = WFmarket.objects.filter(cn_name__icontains=keyword)
查询Filter的字段包含关键词匹配逻辑(匹配大小写字母敏感),代码示例:
    markets = WFmarket.objects.filter(cn_name__contains=keyword)

你可能感兴趣的:(Django框架 之 查询 Extra的where里如何写like前/后置匹配逻辑)