0

I have defined a model MyUser in two apps(let's say A and B) in different projects in django with the same DB(CAP_db). The second project uses more than one DB. So, when querying the model MyUser in one of its apps, I am using the statement : ambassador = MyUser.objects.using('CAP_db').get(code=code).

By default, Django is creating the two tables a_myuser and b_myuser for the model from the two different apps. Is there any way to direct the query from one particular table( from the different project i.e. a_myuser)?

Note: The model doesn't contain any foreign key nor is used as a foreign key in any other model. Also, the views.py for the query doesn't import any models from any app.

2
  • This can be done by using A.objects.raw() as you can do your own select Commented Jul 13, 2021 at 13:43
  • This way, won't the model not be accessible in the other project and the error A is not defined will be returned? Commented Jul 22, 2021 at 7:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.