简体   繁体   English

Python django,检查 sql 列是否包含值

[英]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.

相关问题 Python-检查列是否包含列表中的值,并返回值 - Python - Check if column contains value in list, return value Python Pandas:如何检查列值是否包含 3 个或更多重复数字 - Python Pandas: How to Check if Column Value Contains 3 or More Repeated Digits 检查csv单元格是否包含字符串并修改Python中的列值 - Check if csv cell contains a string and modify column value in Python Django-如何检查表列中是否包含id? - Django - How to check if id contains in a table column? Pandas Python,如何搜索列以检查它是否包含某个字符串值,以便它在新列中返回一个值 - Pandas Python, how to search a column to check if it contains a certain string value so it returns a value in a new column Pandas: Python 检查多列如果包含值然后将值返回到新列 - Pandas: Python check Multiple columns if contains value then return value to new column 检查 Pandas 列是否包含来自另一列的值 - Check if Pandas column contains value from another column 检查一列是否包含来自python pandas中另一列的数据 - Check if a column contains data from another column in python pandas 如果Contains()为True,Python将值分配给新列 - Python Assign Value to New Column If Contains() Is True 如果字符串包含在文件名中,则将值添加到列中(python 3) - If string contains in filename, then add value to column (python 3)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM