#29545: Nested OuterRef not looking on the right model for the field. -------------------------------------+------------------------------------- Reporter: Aaron Lisman | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 2.0 (models, ORM) | Severity: Normal | Resolution: Keywords: outerref, subquery | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Oskar Persson): I also ran into this just now and can confirm that the bug exists in both 2.2.4 and master, tested with the models in tests/queries/models.py: {{{ def test_nested_outerref(self): from .models import Item, Node, Number Number.objects.create(num=5) Node.objects.create(num=5) qs = Number.objects.annotate( has_item=Exists( Item.objects.annotate( has_tag=Exists( Node.objects.filter(num=OuterRef(OuterRef('num'))) ) ).filter(has_tag=True) ) ) print(qs) }}} This results in the following exception {{{ django.core.exceptions.FieldError: Cannot resolve keyword 'num' into field. Choices are: cover, created, creator, creator_id, has_tag, id, modified, name, note, note_id, tags }}} -- Ticket URL: <https://code.djangoproject.com/ticket/29545#comment:4> 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/063.e7f51ab1511811336a16414bf7c2b771%40djangoproject.com.