Davronbek | SWE πŸͺ
890 subscribers
583 photos
113 videos
66 files
449 links
More: Python | Go | VueJs

- Loyihalardagi xatoliklar va ularni xal qilishdagi ba'zi tavsiyalarni yozib boraman.

Don't be shy, say hi πŸ‘‹ | @firdavs_dev | https://davronbekdev.uz
Download Telegram
Forwarded from PyNotes
#Django_ORM #filters
Subquery

Django allows using SQL subqueries. Let’s start with something simple, We have a UserParent model which has OnetoOne relation with auth user. We will find all the UserParent which have a UserParent.

from
django.db.models import Subquery
users = User.objects.all()
UserParent.objects.filter(user_id__in=Subquery(users.values('id')))

#source
https://books.agiliq.com/projects/django-orm-cookbook/en/latest/subquery.html
πŸ€·β€β™€5πŸ‘2πŸ”₯2