settings.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. """
  2. Django settings for Niko project.
  3. Generated by 'django-admin startproject' using Django 1.9.1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/1.9/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/1.9/ref/settings/
  8. """
  9. import os
  10. import posixpath
  11. import captcha
  12. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  13. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  14. # Quick-start development settings - unsuitable for production
  15. # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
  16. # SECURITY WARNING: keep the secret key used in production secret!
  17. SECRET_KEY = '3eab158c-8531-4c6b-800e-9181f6511a41'
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = True
  20. ALLOWED_HOSTS = ['www.qiandao.name', '127.0.0.1','qiandao.name','localhost']
  21. # Application definition
  22. INSTALLED_APPS = [
  23. # Add your apps here to enable them
  24. 'django.contrib.admin',
  25. 'django.contrib.auth',
  26. 'django.contrib.contenttypes',
  27. 'django.contrib.sessions',
  28. 'django.contrib.messages',
  29. 'django.contrib.staticfiles',
  30. 'checkIn',
  31. 'captcha',
  32. 'dati',
  33. 'library',
  34. ]
  35. MIDDLEWARE_CLASSES = [
  36. 'django.middleware.security.SecurityMiddleware',
  37. 'django.contrib.sessions.middleware.SessionMiddleware',
  38. 'django.middleware.common.CommonMiddleware',
  39. 'django.middleware.csrf.CsrfViewMiddleware',
  40. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  41. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  42. 'django.contrib.messages.middleware.MessageMiddleware',
  43. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  44. ]
  45. ROOT_URLCONF = 'Niko.urls'
  46. TEMPLATES = [
  47. {
  48. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  49. 'DIRS': [],
  50. 'APP_DIRS': True,
  51. 'OPTIONS': {
  52. 'context_processors': [
  53. 'django.template.context_processors.debug',
  54. 'django.template.context_processors.request',
  55. 'django.contrib.auth.context_processors.auth',
  56. 'django.contrib.messages.context_processors.messages',
  57. ],
  58. },
  59. },
  60. ]
  61. WSGI_APPLICATION = 'Niko.wsgi.application'
  62. # Database
  63. # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
  64. DATABASES = {
  65. # 使用sqlite3
  66. 'default': {
  67. 'ENGINE': 'django.db.backends.sqlite3',
  68. 'NAME': os.path.join(BASE_DIR, 'APP_data/db.sqlite3'),
  69. },
  70. # 使用mysql,需要pip install mysqlclient。手机号码需要设置为BIGINT
  71. #'default': {
  72. # "ENGINE": "django.db.backends.mysql",
  73. # "NAME": "nico_db",
  74. # "USER": "nico",
  75. # "PASSWORD": "qwer1234TYUI%^&*",
  76. # "HOST": "localhost",
  77. # "PORT": "3306",
  78. #},
  79. }
  80. # Password validation
  81. # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
  82. AUTH_PASSWORD_VALIDATORS = [
  83. {
  84. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  85. },
  86. {
  87. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  88. },
  89. {
  90. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  91. },
  92. {
  93. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  94. },
  95. ]
  96. # Internationalization
  97. # https://docs.djangoproject.com/en/1.9/topics/i18n/
  98. LANGUAGE_CODE = 'zh-Hans'
  99. TIME_ZONE = 'Asia/Shanghai'
  100. USE_I18N = True
  101. USE_L10N = True
  102. USE_TZ = True
  103. # Static files (CSS, JavaScript, Images)
  104. # https://docs.djangoproject.com/en/1.9/howto/static-files/
  105. STATIC_URL = '/static/'
  106. STATIC_ROOT = posixpath.join(*(BASE_DIR.split(os.path.sep) + ['static']))
  107. # CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
  108. CAPTCHA_LETTER_ROTATION = (-10,10)
  109. CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_dots',)
  110. CACHES= {
  111. 'default': {
  112. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  113. }
  114. }
  115. CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
  116. CAPTCHA_MATH_CHALLENGE_OPERATOR = 'x'