Hi,
Using Django 1.8.3, I have 2 models, both unmanaged (remote DB managed by another system), with something similar to that:
class Parent(Model):
... some fields...
class Child(Model):
id = OneToOneField(primary_key=True, parent_link=True)
... some other fields ...
Notes:
- Parent is not abstract.
- Each of the models have their own real tables.
- Not using model inheritance because I want the parent_link field to be called "id" (as the db column), and Django doesn't allow hiding fields (with the same name).
Given all that, using select_related('id') in a Child QuerySet doesn't work (no exception but the Parent fields aren't fetched in the same DB query).
In order to workaround the issue, I removed the parent_link attribute (note that as the tables are unmanaged, this attribute, and others, exist merely as documentation, so I can remove it).
Without the parent_link attribute, the Child fields are indeed fetched in the same DB query, as expected from select_related().
Is it a bug in Django or something I'm missing?