title: Django: using same test database in a separate thread
body: <p>I am running pytests using a test database with the following DB settings.</p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'postgres',
          'USER': 'something',
          'PASSWORD': 'password',
  
      },
  }
  </code></pre>
  
  <p>Using the @pytest.mark.django_db, my test functions access a database called 'test_postgres' created for the tests.</p>
  
  <pre><code>@pytest.mark.django_db
  def test_example():
      from django.db import connection
      cur_ = connection.cursor()
      print cur_.db.settings_dict
  </code></pre>
  
  <p>outputs:</p>
  
  <pre><code>{'ENGINE': 'django.db.backends.postgresql_psycopg2', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'test_postgres', 'TEST_MIRROR': None,...
  </code></pre>
  
  <p>but if I run a thread inside test_example:</p>
  
  <pre><code>def function_to_run():
      from django.db import connection
      cur_ = connection.cursor
      logger.error(cur_.db.settings_dict)
  
  @pytest.mark.django_db
  def test_example():
      p = multiprocessing.Process(target=function_to_run)
      p.start()
  </code></pre>
  
  <p>I can see that in that thread the cursor is using database named 'postgres' which is the non-testing database. Output:</p>
  
  <pre><code>{'ENGINE': 'django.db.backends.postgresql_psycopg2', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'postgres', 'TEST_MIRROR': None,...
  </code></pre>
  
  <p>Is there a way to pass a database connection argument to my thread from the original test function and tell my thread routine to use the same database name ('test_postgres') as my test function?</p>