title: DJango testing multiple database application
body: <p>I have django application which has two database <code>defaultdb</code> and <code>externdb</code></p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          &quot;NAME&quot;: config(&quot;DB_NAME&quot;),
          &quot;USER&quot;: config(&quot;DB_USER&quot;),
          &quot;PASSWORD&quot;: config(&quot;DB_PASSWORD&quot;),
          &quot;HOST&quot;: config(&quot;DB_HOST&quot;),
          &quot;PORT&quot;: config(&quot;DB_PORT&quot;),
          'OPTIONS': {
              'charset': 'utf8mb4',
              'init_command': &quot;SET sql_mode='STRICT_TRANS_TABLES'&quot;
          },
          'TEST': {
              'NAME': 'test_{0}'.format(config(&quot;DB_NAME&quot;)),
              'MIRROR': &quot;default&quot;,
          },
      },
      'extern': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': config(&quot;DB_EXTERN_NAME&quot;),
          'USER': config(&quot;DB_EXTERN_USER&quot;),
          'PASSWORD': config(&quot;DB_EXTERN_PASSWORD&quot;),
          'HOST': config(&quot;DB_EXTERN_HOST&quot;),
          'PORT': config(&quot;DB_EXTERN_PORT&quot;),
          'TEST': {
              'NAME': 'test_{0}'.format(config(&quot;DB_EXTERN_NAME&quot;)),
              'MIRROR': &quot;extern&quot;,
          },
      }
  }
  </code></pre>
  <p>The application works well but when testing ,this error occurs below</p>
  <p>when trying to access the extern database</p>
  <pre><code>from extern_db.models import TBasicInfo
  
  class HelpViewTest(TestCase):
      def test_api(self):
          tb = TBasicInfo.objects.get(info_id=10352)
  </code></pre>
  <p>This error occurs</p>
  <pre><code>AssertionError: Database queries to 'extern' are not allowed in this test. Add 'extern' to defapp.tests.HelpViewTest.databases to ensure proper test isolation and silence this failure.
  </code></pre>
  <p>which setting should I check??</p>