#30379: ProgrammingError from exclude using models.F with long relation -------------------------------------+------------------------------------- Reporter: PeterJCLaw | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: 2.2 (models, ORM) | Severity: Normal | Resolution: duplicate Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by PeterJCLaw): Interestingly, attempting to cut this down further results in both the relative and specific spellings of the query emitting similar errors. Given: {{{#!python class Item(models.Model): name = models.TextField() class UserItem(models.Model): user = models.ForeignKey('auth.User', on_delete=models.CASCADE) item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='user_items') class Alert(models.Model): user = models.ForeignKey('auth.User', on_delete=models.CASCADE) item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='alerts') }}} then both {{{#!python Alert.objects.exclude(item__order_items__user=models.F('user')) }}} and {{{#!python Alert.objects.exclude(item__order_items__user=the_user) }}} both emit `ProgrammingError`s. -- Ticket URL: <https://code.djangoproject.com/ticket/30379#comment:3> 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/068.15a2d568e20fda6c34d10f88e453ab5a%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.