2👍
Figured it out, guys. The trick is to specify the db being used with a variable. The DATABASES key returns a different list depending on whether the code is running as a test or normally.
from django.conf import settings
if 'myDb' in settings.DATABASES:
db = 'myDb'
else:
db = 'default'
with transaction.atomic(using=db):
...
Source:stackexchange.com