def init_django():
 global django, management, create_test_db, destroy_test_db
 global setup_test_environment, teardown_test_environment
 if (not django):
  return
 from django.core import management
 project_dir = management.setup_environ(settings)
 sys.path.insert(0, project_dir)
 try:
  from django.test.utils import create_test_db, destroy_test_db
 except ImportError:
  from django.db import connection
  create_test_db = connection.creation.create_test_db
  destroy_test_db = connection.creation.destroy_test_db
 from django.test.utils import setup_test_environment, teardown_test_environment
 return True

def init_django ( ) : global django , management , create_test_db , destroy_test_db global setup_test_environment , teardown_test_environment if ( not django ) : return from django . core import management project_dir = management . setup_environ ( settings ) sys . path . insert ( 0 , project_dir ) try : from django . test . utils import create_test_db , destroy_test_db except ImportError : from django . db import connection create_test_db = connection . creation . create_test_db destroy_test_db = connection . creation . destroy_test_db from django . test . utils import setup_test_environment , teardown_test_environment return True
bootstrap django and initialise this module .