[英]Python django, check if sql column contains a value
Is there a way to check if a table column already contain a value without using a for loop?有没有办法在不使用 for 循环的情况下检查表列是否已经包含一个值?
Does django have a "not in" syntax? django 是否有“不在”语法?
You can use something like this...你可以使用这样的东西......
# Check for null
YourModel.objects.filter(yourcolumn__isnull=True).all()
# Check for empty string
YourModel.objects.filter(yourcolumn='').all()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.