settings.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. """
  2. Django settings for hellodjango project.
  3. Generated by 'django-admin startproject' using Django 2.0.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.0/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = 'j*jr(3-it8$lrp&u@e^!f%8!ws*=jx)ga*ln%l6aqftu-uy1=1'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = []
  19. SESSION_EXPIRE_AT_BROWSER_CLOSE = False
  20. SESSION_COOKIE_AGE = 1800
  21. # Application definition
  22. INSTALLED_APPS = [
  23. 'django.contrib.admin',
  24. 'django.contrib.auth',
  25. 'django.contrib.contenttypes',
  26. 'django.contrib.sessions',
  27. 'django.contrib.messages',
  28. 'django.contrib.staticfiles',
  29. 'demo',
  30. ]
  31. MIDDLEWARE = [
  32. 'django.middleware.security.SecurityMiddleware',
  33. 'django.contrib.sessions.middleware.SessionMiddleware',
  34. 'django.middleware.common.CommonMiddleware',
  35. 'django.middleware.csrf.CsrfViewMiddleware',
  36. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  37. 'django.contrib.messages.middleware.MessageMiddleware',
  38. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  39. ]
  40. ROOT_URLCONF = 'hellodjango.urls'
  41. TEMPLATES = [
  42. {
  43. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  44. 'DIRS': [os.path.join(BASE_DIR, 'templates'),],
  45. 'APP_DIRS': True,
  46. 'OPTIONS': {
  47. 'context_processors': [
  48. 'django.template.context_processors.debug',
  49. 'django.template.context_processors.request',
  50. 'django.contrib.auth.context_processors.auth',
  51. 'django.contrib.messages.context_processors.messages',
  52. ],
  53. },
  54. },
  55. ]
  56. WSGI_APPLICATION = 'hellodjango.wsgi.application'
  57. # Database
  58. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  59. DATABASES = {
  60. 'default': {
  61. 'ENGINE': 'django.db.backends.mysql',
  62. 'NAME': 'demo',
  63. 'HOST': 'localhost',
  64. 'PORT': 3306,
  65. 'USER': 'root',
  66. 'PASSWORD': '123456',
  67. }
  68. }
  69. # Password validation
  70. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  71. AUTH_PASSWORD_VALIDATORS = [
  72. {
  73. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  74. },
  75. {
  76. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  77. },
  78. {
  79. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  80. },
  81. {
  82. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  83. },
  84. ]
  85. # Internationalization
  86. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  87. LANGUAGE_CODE = 'zh-hans'
  88. TIME_ZONE = 'Asia/Chongqing'
  89. # internationalization
  90. USE_I18N = True
  91. # localization
  92. USE_L10N = True
  93. USE_TZ = True
  94. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
  95. # Static files (CSS, JavaScript, Images)
  96. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  97. STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
  98. STATIC_URL = '/static/'
  99. # APPEND_SLASH = False
  100. # DEBUG < INFO < WARNING < ERROR < CRITICAL
  101. LOGGING = {
  102. 'version': 1,
  103. 'disable_existing_loggers': False,
  104. 'handlers': {
  105. 'console': {
  106. 'class': 'logging.StreamHandler',
  107. },
  108. },
  109. 'loggers': {
  110. 'django': {
  111. 'handlers': ['console'],
  112. 'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
  113. },
  114. },
  115. }