Re: Pass or refer parent query value into subquery

2022-07-26 Thread Ross Meredith
Sorry I haven't used the JSONField myself before. On Tue, Jul 26, 2022 at 5:01 PM Sencer Hamarat wrote: > Thanks Ross, > Very appreciated. > That's what I need. > > I'm also having a problem with this query after I implemented the solution: > > I believe, >

Re: Pass or refer parent query value into subquery

2022-07-26 Thread Sencer Hamarat
Thanks Ross, Very appreciated. That's what I need. I'm also having a problem with this query after I implemented the solution: I believe, Q(bundle__contains=OuterRef("book_id")) part of the query is expecting an array instead of direct value. I'm getting this error: ProgrammingError: operator

Re: Pass or refer parent query value into subquery

2022-07-26 Thread Ross Meredith
https://docs.djangoproject.com/en/4.0/ref/models/expressions/#django.db.models.OuterRef On Tue, Jul 26, 2022 at 4:27 PM Sencer Hamarat wrote: > Hi, > > I need to pass the parent query book_id value into the subquery. > Here is the model and the current state of the query I reached. > > class

Pass or refer parent query value into subquery

2022-07-26 Thread Sencer Hamarat
Hi, I need to pass the parent query book_id value into the subquery. Here is the model and the current state of the query I reached. class Publisher(models.Model): book = models.ForeignKey(Book) bundle = models.JSONField() current_sales_count_query = Publisher.objects.filter(