#29762: Explicit 'Using' with foreign Key on model -------------------------------------+------------------------------------- Reporter: Vackar | Owner: nobody Afzal | Type: | Status: new Uncategorized | Component: Database | Version: 2.0 layer (models, ORM) | Severity: Normal | Keywords: oracle, multidb Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- When run a filter query like this:
{{{ my_instance = MyModel.objects.using('NonDefaultDBConn').filter(some_field='XXXX') my_instance.local_field #This works my_instance.fk_field #This doesn't work }}} It fails when trying to access my_instance.fk_field as it defaults to using the 'default' connection and not 'NonDefaultDBConn' I would assume that when fetching a model using 'NonDefaultDBConn' that all subsequent lookups should go through 'NonDefaultDBConn' and not 'default' If this is not the case, and this is expected behaviour how can I force fk lookups to go through 'NonDefaultDBConn' I know I can run {{{ MyLinkedModel.objects.filter(x_instance=my_instance) }}} But this is massively in-efficient both from a performance and code maintainability point of view. I am using Django 2.0 with the Oracle backend. -- Ticket URL: <https://code.djangoproject.com/ticket/29762> 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/054.7ef2b521b5363318a0f6c1f92aa34d1e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.