settings.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. """
  2. Django settings for app project.
  3. Generated by 'django-admin startproject' using Django 4.0.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/4.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/4.0/ref/settings/
  8. """
  9. import os
  10. import json
  11. import socket
  12. from pathlib import Path
  13. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  14. BASE_DIR = Path(__file__).resolve().parent.parent
  15. # Quick-start development settings - unsuitable for production
  16. # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
  17. # SECURITY WARNING: keep the secret key used in production secret!
  18. SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'debug_secret_key')
  19. # SECURITY WARNING: don't run with debug turned on in production!
  20. DEBUG = os.getenv('DJANGO_DEBUG', "True") == "True"
  21. if DEBUG:
  22. hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
  23. INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "localhost"]
  24. ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
  25. CSRF_TRUSTED_ORIGINS = os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS', 'http://localhost').split(',')
  26. # Application definition
  27. INSTALLED_APPS = [
  28. 'zitap.apps.ZitapConfig',
  29. 'django.contrib.admin',
  30. 'django.contrib.auth',
  31. 'django.contrib.contenttypes',
  32. 'django.contrib.sessions',
  33. 'django.contrib.messages',
  34. 'django.contrib.staticfiles',
  35. 'debug_toolbar',
  36. ]
  37. MIDDLEWARE = [
  38. 'django.middleware.security.SecurityMiddleware',
  39. 'django.contrib.sessions.middleware.SessionMiddleware',
  40. 'django.middleware.common.CommonMiddleware',
  41. 'django.middleware.csrf.CsrfViewMiddleware',
  42. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  43. 'django.middleware.locale.LocaleMiddleware',
  44. 'django.contrib.messages.middleware.MessageMiddleware',
  45. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  46. "debug_toolbar.middleware.DebugToolbarMiddleware",
  47. ]
  48. LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
  49. ROOT_URLCONF = 'project.urls'
  50. TEMPLATES = [
  51. {
  52. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  53. 'DIRS': [],
  54. 'APP_DIRS': True,
  55. 'OPTIONS': {
  56. 'context_processors': [
  57. 'django.template.context_processors.debug',
  58. 'django.template.context_processors.request',
  59. 'django.contrib.auth.context_processors.auth',
  60. 'django.contrib.messages.context_processors.messages',
  61. ],
  62. },
  63. },
  64. ]
  65. WSGI_APPLICATION = 'project.wsgi.application'
  66. # Database
  67. # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
  68. DATABASES = {
  69. 'default': {
  70. 'ENGINE': 'django.db.backends.sqlite3',
  71. 'NAME': BASE_DIR / 'db.sqlite3',
  72. }
  73. }
  74. DATABASES = {
  75. 'default': {
  76. 'ENGINE': os.getenv('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
  77. 'NAME': os.getenv('DATABASE_NAME', 'db.sqlite3'),
  78. 'USER': os.getenv('DATABASE_USERNAME', 'myprojectuser'),
  79. 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'password'),
  80. 'HOST': os.getenv('DATABASE_HOST', '127.0.0.1'),
  81. 'PORT': os.getenv('DATABASE_PORT', 3306),
  82. 'OPTIONS': json.loads(
  83. os.getenv('DATABASE_OPTIONS', '{}')
  84. ),
  85. }
  86. }
  87. # Password validation
  88. # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
  89. AUTH_PASSWORD_VALIDATORS = [
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  95. },
  96. {
  97. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  98. },
  99. {
  100. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  101. },
  102. ]
  103. # Internationalization
  104. # https://docs.djangoproject.com/en/4.0/topics/i18n/
  105. LANGUAGE_CODE = 'en-us'
  106. TIME_ZONE = 'UTC'
  107. USE_I18N = True
  108. USE_L10N = True
  109. USE_TZ = True
  110. # Static files (CSS, JavaScript, Images)
  111. # https://docs.djangoproject.com/en/4.0/howto/static-files/
  112. STATIC_URL = 'static/'
  113. STATIC_ROOT = '/static/static'
  114. # Default primary key field type
  115. # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
  116. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  117. MEDIA_ROOT = os.path.join(BASE_DIR, '../data')
  118. DATA_UPLOAD_MAX_NUMBER_FIELDS = 2 * 4*24*5*7