def _django_setup():
  """Imports and configures Django.

  This can be overridden by defining a function named
  webapp_django_setup() in the app's appengine_config.py file (see
  lib_config docs).  Such a function should import and configure
  Django.

  In the Python 2.5 runtime, you can also just configure the Django version to
  be used by setting webapp_django_version in that file.

  Finally, calling use_library('django', <version>) in that file
  should also work:

    # Example taken from from
    # https://developers.google.com/appengine/docs/python/tools/libraries#Django

    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

    from google.appengine.dist import use_library
    use_library('django', '1.2')

  In the Python 2.7 runtime, the Django version is specified in you app.yaml
  file and use_library is not supported.

  If your application also imports Django directly it should ensure
  that the same code is executed before your app imports Django
  (directly or indirectly).  Perhaps the simplest way to ensure that
  is to include the following in your main.py (and in each alternate
  main script):

    from google.appengine.ext.webapp import template
    import django

  This will ensure that whatever Django setup code you have included
  in appengine_config.py is executed, as a side effect of importing
  the webapp.template module.
  """
  if os.environ.get('APPENGINE_RUNTIME') != 'python27':
    __django_version_setup()


  import django


  import django.conf
  try:

    raise ImportError
    # TODO: Right now the below line raises a
    # django.core.exceptions.ImproperlyConfigured exception. Need to investigate
    # why and address accordingly.
    #getattr(django.conf.settings, 'FAKE_ATTR', None)
  except (__HOLE__, EnvironmentError), e:



    if os.getenv(django.conf.ENVIRONMENT_VARIABLE):


      logging.warning(e)

    try:
      django.conf.settings.configure(
        DEBUG=False,
        TEMPLATE_DEBUG=False,
        TEMPLATE_LOADERS=(
          'django.template.loaders.filesystem.load_template_source',
        ),
      )
    except (EnvironmentError, RuntimeError):



      pass
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/webapp/__init__.py/_django_setup