Currently, when referencing any foreign keys, (many to many, one to many) DRF seems to grab the information from the default (auth) database, so I get errors saying "relation does not exist" because there is not a table that exists within the auth db for what I am trying to get. I would like it to choose from the same database as request. Is there any way to get request (or self) inside of a serializer so I can choose the db from that? I believe it is possible on create/update using
def to_internal_value(self, data):
request = self.context.get('request')
But this is only called on create/update, is there a way to do so when just listing the values? My initial query (from viewset) selects from the correct db as I can choose it via request, but when it goes through the serializer it tries to get foreign keys from default (auth) db. There must be some way to specify the database and not have it use default right?