Tutorial by Examples

To use multiple databases in Django, just specify each one in settings.py: DATABASES = { 'default': { 'NAME': 'app_data', 'ENGINE': 'django.db.backends.postgresql', 'USER': 'django_db_user', 'PASSWORD': os.environ['LOCAL_DB_PASSWORD'] }, 'users': {...
The normal obj.save() method will use the default database, or if a database router is used, it will use the database as specified in db_for_write. You can override it by using: obj.save(using='other_db') obj.delete(using='other_db') Similarly, for reading: MyModel.objects.using('other_db').al...

Page 1 of 1