text: """
  Django settings for opencmdb project.
  
  Generated by 'django-admin startproject' using Django 1.9.7.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/1.9/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.9/ref/settings/
  """
  
  import os, datetime
  
  PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                              os.pardir))
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = '-#03d2lzrn!_&d545e*%()6kv&((48@d7hutvn%!0ej6gk&*70'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '192.168.56.13', 'cmdb.unixhot.com']
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  
      'django_mongoengine',
      'django_mongoengine.mongo_auth',
      'django_mongoengine.mongo_admin.sites',
      'django_mongoengine.mongo_admin',
      'rest_framework',
      'rest_framework_mongoengine',
  
      'opencmdb',
      'arch',
      'item',
      'api',
  ]
  
  MIDDLEWARE_CLASSES = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
      'mydecorators.UserActionLoggingMiddleware',
  ]
  
  
  
  REST_FRAMEWORK = {
      'DEFAULT_PERMISSION_CLASSES': (
          'rest_framework.permissions.IsAuthenticated',
      ),
      'DEFAULT_AUTHENTICATION_CLASSES': (
          # 'rest_framework.authentication.SessionAuthentication',
          # 'rest_framework.authentication.BasicAuthentication',
          'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
      ),
      'FORM_METHOD_OVERRIDE': None,
      'FORM_CONTENT_OVERRIDE': None,
      'FORM_CONTENTTYPE_OVERRIDE': None
  
  }
  
  
  JWT_AUTH = {
      'JWT_ENCODE_HANDLER':
      'rest_framework_jwt.utils.jwt_encode_handler',
  
      'JWT_DECODE_HANDLER':
      'rest_framework_jwt.utils.jwt_decode_handler',
  
      'JWT_PAYLOAD_HANDLER':
      'rest_framework_jwt.utils.jwt_payload_handler',
  
      'JWT_PAYLOAD_GET_USER_ID_HANDLER':
      'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
  
      'JWT_RESPONSE_PAYLOAD_HANDLER':
      'rest_framework_jwt.utils.jwt_response_payload_handler',
  
      'JWT_SECRET_KEY': SECRET_KEY,
      'JWT_PUBLIC_KEY': None,
      'JWT_PRIVATE_KEY': None,
      'JWT_ALGORITHM': 'HS256',
      'JWT_VERIFY': True,
      'JWT_VERIFY_EXPIRATION': True,
      'JWT_LEEWAY': 0,
      'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=30000),
      'JWT_AUDIENCE': None,
      'JWT_ISSUER': None,
  
      'JWT_ALLOW_REFRESH': True,
      'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7),
  
      'JWT_AUTH_HEADER_PREFIX': 'JWT',
  }
  
  MEDIA_URL = "/media/"
  MEDIA_ROOT = os.path.join(PROJECT_ROOT, "media")
  
  ROOT_URLCONF = 'opencmdb.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates')]
          ,
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'opencmdb.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
  
  from decouple import config
  import dj_database_url
  
  
  # Password validation
  # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/1.9/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'Asia/Shanghai'
  
  USE_I18N = True
  
  USE_L10N = True
  
  # USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/1.9/howto/static-files/
  
  STATIC_URL = '/static/'
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  
  import mongoengine
  
  SESSION_ENGINE = 'django_mongoengine.sessions'
  SESSION_SERIALIZER = 'django_mongoengine.sessions.BSONSerializer'
  
  mongodb_url=config('MONGODB_URL', '127.0.0.1')
  
  MONGODB_DATABASES = {
      "default": {
          "name": 'cmdb',
          # "host": mongodb_url,
          "host": '127.0.0.1',        
          # "password": 'cmdb',
          # "username": 'cmdb',
          "tz_aware": True,  # if you using timezones in django (USE_TZ = True)
      },
  }
  
  AUTHENTICATION_BACKENDS = (
      'django_mongoengine.mongo_auth.backends.MongoEngineBackend',
  )
  AUTH_USER_MODEL = 'mongo_auth.MongoUser'
  
  try:
      from opencmdb.server_conf import *
  except ImportError:
      pass
  
  try:
      from opencmdb.local_conf import *
  except ImportError:
      pass
  