惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
G
Google Developers Blog
D
Docker
The GitHub Blog
The GitHub Blog
H
Help Net Security
WordPress大学
WordPress大学
博客园_首页
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
罗磊的独立博客
I
InfoQ
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Jina AI
Jina AI
J
Java Code Geeks
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News

博客园 - 风来风往风伤(TiAmo)

CPU监控工具 桌面日历软件 no matching host key type found. Their offer: ssh-rsa报错信息具体方法 Spring_AOP 原理 增强类型 js漂浮代码 ThoughtWorks(中国)程序员读书雷达 Java实现文件的RSA和DES加密算法 二维码 编码原理简介 Maven+eclipse+svn项目构建 QtCreator中使用CMake+Ninja加速编译 error C1088: 无法刷新编译器中间文件 error C1041: 无法打开程序数据库“xxx\vc140.pdb”;如果要将多个 CL.EXE 写入同一个 .PDB 文件 - 风来风往风伤(TiAmo) Navicat key MICROSOFT SQL SERVER 2012 序列号 IT外包概要 RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set. QEventLoop配合QTimer实现阻塞任务超时处理 sql调优的总结 2019Python学习路线图
判断django中的orm为空
风来风往风伤(TiAmo) · 2019-06-10 · via 博客园 - 风来风往风伤(TiAmo)
result= Booking.objects.filter()
 
 
#方法一 .exists()
if result.exists():
    print "QuerySet has Data"
else:
    print "QuerySet is empty"
#方法二 .count()==0
if result.count() == 0:
    print "empty"
#方法三
if result:
    print "QuerySet has Data"
else:
    print "QuerySet is empty"
 
总结:
QuerySet.exists() > QuerySet.count()==0 > QuerySet