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

推荐订阅源

Last Week in AI
Last Week in AI
D
DataBreaches.Net
腾讯CDC
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
罗磊的独立博客
月光博客
月光博客
MyScale Blog
MyScale Blog
U
Unit 42
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
G
Google Developers Blog
博客园 - 【当耐特】
D
Docker
I
InfoQ
雷峰网
雷峰网

博客园 - 风来风往风伤(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