22π
β
The Django: Multiple Databases page contains good information on this topic. After you have configured your databases in settings.py, you can use .using()
to specify the database you wish to query.
Examples from the documentation:
>>> # This will run on the 'default' database.
>>> Author.objects.all()
>>> # So will this.
>>> Author.objects.using('default').all()
>>> # This will run on the 'other' database.
>>> Author.objects.using('other').all()
π€George Cummins
4π
sure, you just have to use
SomeObject.objects.using('database_name').all()
to do your queries
- Enable PK based filtering in Django Graphene Relay while retaining Global IDs
- Should I iterate on django query set or over the variable?
Source:stackexchange.com