#28621: Crash in QuerySet.annotate() with OuterRef -------------------------------------+------------------------------------- Reporter: Дилян Палаузов | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.11 (models, ORM) | Severity: Normal | Resolution: Keywords: QuerySet.extra | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Ben Davis): I am also getting this error. Is there a workaround? `AttributeError: 'ResolvedOuterRef' object has no attribute 'contains_aggregate'` My query looks like this: {{{#!python class ProgramQuerySet(models.QuerySet): def with_remaining_volunteers_needed(self): sessions_query = ( Session.objects .filter(program=OuterRef('id')) .annotate(needed=OuterRef('volunteers_per_session') - Count('volunteer_attendances')) .order_by('-needed') .values('needed')[:1] ) return self.annotate( volunteers_per_session=(F('num_student_seats') * F('student_volunteer_ratio')), needed=Subquery(sessions_query, output_field=models.IntegerField()) ) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/28621#comment:6> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/072.97b6cf956b3129ea281d6596cd21dd7b%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.