settings.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. """
  2. Django settings for system project.
  3. Generated by 'django-management startproject' using Django 4.2.3.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/4.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/4.2/ref/settings/
  8. """
  9. import os
  10. from pathlib import Path
  11. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  12. BASE_DIR = Path(__file__).resolve().parent.parent
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'django-insecure-e$=2ugc1&8s)+2qr-3w^b3309(coxep^a@jcc*+0t$_vrn#hsx'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['*'] # 修改后,表示任何域名都能访问。如果指定域名的话,在''里放入指定的域名即可
  20. # Application definition
  21. INSTALLED_APPS = [
  22. 'django.contrib.admin',
  23. 'django.contrib.auth',
  24. 'django.contrib.contenttypes',
  25. 'django.contrib.sessions',
  26. 'django.contrib.messages',
  27. 'django.contrib.staticfiles',
  28. 'blog.apps.BlogConfig',
  29. 'blog.templatetags',
  30. 'avatar'
  31. ]
  32. MIDDLEWARE = [
  33. 'django.middleware.security.SecurityMiddleware',
  34. 'django.contrib.sessions.middleware.SessionMiddleware',
  35. 'django.middleware.common.CommonMiddleware',
  36. 'django.middleware.csrf.CsrfViewMiddleware',
  37. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  38. 'django.contrib.messages.middleware.MessageMiddleware',
  39. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  40. 'system.middleware.ExceptionMiddleware'
  41. ]
  42. ROOT_URLCONF = 'system.urls'
  43. TEMPLATES = [
  44. {
  45. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  46. 'DIRS': [BASE_DIR / 'templates'],
  47. 'APP_DIRS': True,
  48. 'OPTIONS': {
  49. 'context_processors': [
  50. 'django.template.context_processors.debug',
  51. 'django.template.context_processors.request',
  52. 'django.contrib.auth.context_processors.auth',
  53. 'django.contrib.messages.context_processors.messages',
  54. 'blog.context_processors.global_content'
  55. ],
  56. },
  57. },
  58. ]
  59. WSGI_APPLICATION = 'system.wsgi.application'
  60. # Database
  61. # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
  62. DATABASES = {
  63. 'default': {
  64. 'ENGINE': 'django.db.backends.sqlite3',
  65. 'NAME': BASE_DIR / 'db.sqlite3',
  66. }
  67. }
  68. # Password validation
  69. # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
  70. AUTH_PASSWORD_VALIDATORS = [
  71. {
  72. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  73. },
  74. {
  75. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  76. },
  77. {
  78. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  79. },
  80. {
  81. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  82. },
  83. ]
  84. # Internationalization
  85. # https://docs.djangoproject.com/en/4.2/topics/i18n/
  86. # LANGUAGE_CODE = 'en-us'
  87. LANGUAGE_CODE = 'zh-hans'
  88. # 把国际时区改为中国时区
  89. # TIME_ZONE = 'UTC'
  90. TIME_ZONE = 'Asia/Shanghai'
  91. USE_I18N = True
  92. USE_TZ = True
  93. # Static files (CSS, JavaScript, Images)
  94. # https://docs.djangoproject.com/en/4.2/howto/static-files/
  95. STATIC_URL = 'static/'
  96. # Default primary key field type
  97. # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
  98. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  99. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
  100. # 这个是设置静态文件夹目录的路径
  101. STATICFILES_DIRS = (
  102. os.path.join(BASE_DIR, 'static'),
  103. )
  104. UPLOAD_URL = '/upload/files'
  105. # UPLOAD_ROOT = '/opt/IBE/files'
  106. UPLOAD_ROOT = 'E:\\opt\\IBE\\files'
  107. DOMAIN = ''
  108. AVATAR_DIR = BASE_DIR.joinpath('avatars')