Hi i'm working in a project with django, and I need to use two differents DB, but I have the next situation, I define my two db's in my settings file, but in both db's i have a table named Personas, which have differents fields name. How could I define my models? My problem is in Meta definition in "db_table" I have the same name in both models. how can i specify which db contains the table?
Asked
Active
Viewed 779 times
1 Answers
0
EDIT: you need to use custom db router, check Django docs Database routers and this SO answer Custom DB router example.
Also you can use QuerySet's method using
to specify database. For example:
User.objects.using('db1').all()
Also you can pass attr using
to save
and delete
methods. For example:
some_object.save(using='db1')
Check here: Django doc: Manually selecting a database

Community
- 1
- 1

Mark Mishyn
- 3,921
- 2
- 28
- 30
-
I've tried but the problem is that, are two differents models, with the same table name, and the tables are in differents DB. I've tried using connections and cursor but don't know how send it to frontend. – Jaime Oct 21 '16 at 14:26