08 2020 档案
摘要:要用django的orm表达sql的exists子查询,需要做两部来完成 from django.db.models import Exists, OuterRef # 1. 定义子查询条件 relative_comments = Comment.objects.filter( post=Outer
阅读全文
摘要:我最近在2019年欧洲Django大会(https://2019.djangocon.eu/ )上发表了一场关于Django ORM的演讲。在这次演讲中,我展示了使用Django ORM进行复杂查询时可以使用的各种技术。这篇文章将部分总结这次演讲,但我也会扩展和添加我无法在30分钟内完成的额外的内容
阅读全文
摘要:原始SQl语句: select ip, group_concat(id) as id from whitelist group by ip; 方法一: Django-ORM实现: 1、创建Concat类: from django.db.models import Aggregate, CharFie
阅读全文