其他分享
首页 > 其他分享> > django 一种动态查询的便捷实现过程

django 一种动态查询的便捷实现过程

作者:互联网

问题引出

解决方案

kwargs = {}
if A is not None:
	kwargs['name_startWith'] = A
if B is not None:
	kwargs['address__contains'] = B
if C is not None:
	kwargs['mobile_endWith'] = C
...
...
personList = Person.objects.filter(**kwargs)
...

标签:...,None,endWith,便捷,contains,查询,kwargs,django
来源: https://blog.csdn.net/kaspar1992/article/details/90726941