settings.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. """
  2. Django settings for second_pro project.
  3. Generated by 'django-admin startproject' using Django 1.10.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/1.10/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/1.10/ref/settings/
  8. """
  9. import os
  10. from django.contrib import admin
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'k6xor0qx47hat_nflfgnccz+e&=jwovam2ec5)g!0zkxq&iwip'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '*',
  20. '120.27.222.26','.yfzhwlw.com','.zgzhwlw.com','iot.hnyfkj.cn',
  21. '39.104.94.153', '.yfznscd.com',
  22. '192.168.1.7'#手机app开发用端口
  23. ]
  24. # Application definition
  25. INSTALLED_APPS = [
  26. 'django.contrib.admin',
  27. 'django.contrib.auth',
  28. 'django.contrib.contenttypes',
  29. 'django.contrib.sessions',
  30. 'django.contrib.messages',
  31. 'django.contrib.staticfiles',
  32. 'apps.AppInfo',
  33. 'apps.Equipment',
  34. 'apps.EquipAllot',
  35. 'apps.Home',
  36. # 将 django-ckeditor 注册到该列表中
  37. 'ckeditor',
  38. 'ckeditor_uploader'
  39. ]
  40. AUTH_USER_MODEL = 'AppInfo.MyUser'
  41. # 当浏览器关闭时,Django会使cookie失效,超时失效和浏览器关闭失效二者只能选择其一
  42. # session回话失效在浏览器关闭时:当为false时,超时失效起作用;
  43. SESSION_EXPIRE_AT_BROWSER_CLOSE = True
  44. MIDDLEWARE = [
  45. 'django.middleware.security.SecurityMiddleware',
  46. 'django.contrib.sessions.middleware.SessionMiddleware',
  47. 'django.middleware.common.CommonMiddleware',
  48. # 'django.middleware.csrf.CsrfViewMiddleware',
  49. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  50. 'django.contrib.messages.middleware.MessageMiddleware',
  51. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  52. ]
  53. ROOT_URLCONF = 'second_pro.urls'
  54. TEMPLATES = [
  55. {
  56. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  57. 'DIRS': [os.path.join(BASE_DIR, 'templates')],
  58. 'APP_DIRS': True,
  59. 'OPTIONS': {
  60. 'context_processors': [
  61. 'django.template.context_processors.debug',
  62. 'django.template.context_processors.request',
  63. 'django.contrib.auth.context_processors.auth',
  64. 'django.contrib.messages.context_processors.messages',
  65. ],
  66. },
  67. },
  68. ]
  69. WSGI_APPLICATION = 'second_pro.wsgi.application'
  70. # Database
  71. # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
  72. DATABASES = {
  73. 'default': {
  74. 'ENGINE': 'django.db.backends.mysql',
  75. 'NAME': 'second',
  76. 'USER': 'second',
  77. 'PASSWORD': 'second',
  78. 'HOST': '127.0.0.1',
  79. 'PORT': '3306',
  80. }
  81. }
  82. # Password validation
  83. # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
  84. AUTH_PASSWORD_VALIDATORS = [
  85. {
  86. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  87. },
  88. {
  89. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  90. },
  91. {
  92. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  93. },
  94. {
  95. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  96. },
  97. ]
  98. # Internationalization
  99. # https://docs.djangoproject.com/en/1.10/topics/i18n/
  100. # 英文改成中文
  101. LANGUAGE_CODE = 'zh-hans'
  102. # 把国际时区改为中国时区
  103. TIME_ZONE = 'Asia/Shanghai'
  104. USE_I18N = True
  105. USE_L10N = True
  106. USE_TZ = False
  107. # Static files (CSS, JavaScript, Images)
  108. # https://docs.djangoproject.com/en/1.10/howto/static-files/
  109. STATIC_URL = '/static/'
  110. # 将静态文件的路径改为模板所在的路径:
  111. # python manage.py collectstatic 命令收集文件位置
  112. STATIC_ROOT = os.path.join(BASE_DIR, "static")
  113. STATICFILES_DIRS = (
  114. os.path.join(BASE_DIR, "templates/static"),)
  115. STATICFILES_FINDERS = (
  116. "django.contrib.staticfiles.finders.FileSystemFinder",
  117. "django.contrib.staticfiles.finders.AppDirectoriesFinder"
  118. )
  119. # CKeditor配置
  120. MEDIA_URL = "/media/"
  121. MEDIA_ROOT = os.path.join(BASE_DIR,"media")
  122. CKEDITOR_UPLOAD_PATH = "uploads/"
  123. CKEDITOR_IMAGE_BACKEND = 'pillow'
  124. CKEDITOR_CONFIGS = {
  125. 'default': {
  126. 'update': ['Image', 'Update', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
  127. 'skin': 'moono',
  128. 'toolbar_Basic': [
  129. ['Source', '-', 'Bold', 'Italic']
  130. ],
  131. 'toolbar_YourCustomToolbarConfig': [
  132. {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']},
  133. {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
  134. {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']},
  135. {'name': 'forms',
  136. 'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
  137. 'HiddenField']},
  138. '/',
  139. {'name': 'basicstyles',
  140. 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
  141. {'name': 'paragraph',
  142. 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
  143. 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
  144. 'Language']},
  145. {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
  146. {'name': 'insert',
  147. 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']},
  148. {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
  149. {'name': 'colors', 'items': ['TextColor', 'BGColor']},
  150. {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
  151. {'name': 'yourcustomtools', 'items': [
  152. # 自定义控件
  153. 'Preview',
  154. 'Maximize',
  155. ]},
  156. ],
  157. 'toolbar': 'YourCustomToolbarConfig', # put selected toolbar config here
  158. 'tabSpaces': 4,
  159. 'extraPlugins': ','.join(
  160. [
  161. # your extra plugins here
  162. 'div',
  163. 'autolink',
  164. 'autoembed',
  165. 'embedsemantic',
  166. 'autogrow',
  167. # 'devtools',
  168. 'widget',
  169. 'lineutils',
  170. 'clipboard',
  171. 'dialog',
  172. 'dialogui',
  173. 'elementspath'
  174. ]),
  175. }
  176. }