#29009: This queryset contains a reference to an outer query and may only be
used
in a subquery
-------------------------------------+-------------------------------------
Reporter: Vasiliy | Owner: nobody
Maryutenkov |
Type: | Status: new
Uncategorized |
Component: Database | Version: 2.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hello
I've tried to serialize queryset with Subquery object and it failed with
that error.
"This queryset contains a reference to an outer query and may only be used
in a subquery"
{{{
subquery =
Transaction.objects.filter(user=OuterRef('pk')).values('user').order_by('user').annotate(txs=Count('*')).annotate(txs_value=Sum(F('tx_value')*F('symbol__price_in_eth'))).annotate(txs_value_eur=Sum((F('tx_value')*F('symbol__price_in_eth'))/eur.price_in_eth))
investors_qs =
User.objects.filter(ether_wallet__isnull=False).annotate(txs=Subquery(subquery.values('txs')[:1])).annotate(txs_value=Subquery(subquery.values('txs_value')[:1])).annotate(txs_value_eur=Subquery(subquery.values('txs_value_eur')[:1]))
jsonpickle.encode(investors_qs.query)
'This queryset contains a reference to an outer query and may '
ValueError: This queryset contains a reference to an outer query and may
only be used in a subquery.
}}}
is it normal behaviour or a bug?
--
Ticket URL: <https://code.djangoproject.com/ticket/29009>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.578be8680a24d2dc266afaae7fa6a51c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.