I have a model User
. For performance and other reasons I have to split this Model and its table into two, UserA
and UserB
. I decided to use materialized views (with the help of django-pgviews). Now what IS easy is to query the data of UserA
which is already in the table, like the username or password. What doesn't work are reverse relationships. Let's say I have a Checkout
model and in this:
user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='checkouts')
When I try to access user.checkouts
, it of course throws an error: Cannot resolve keyword 'checkouts' into field
.
So how can I create a reverse relationship which is accessible from multiple models? I thought about using contenttypes but this seems a bit much for this use case, especially because UserA and UserB are just views and have the same columns.