Python Galery
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

settings.py 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. """
  2. Django settings for this project.
  3. Generated by 'django-admin startproject' using Django 2.2.3.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.2/ref/settings/
  8. """
  9. try:
  10. from config import config
  11. # required keys: SECRET_KEY
  12. # optional keys: ALLOWED_HOSTS, DEFAULT_THEME, ITEM_ROOT, THUMBNAIL_SIZES, WEBNAIL_SIZES
  13. except ImportError:
  14. config = {}
  15. import os
  16. import random
  17. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  18. #
  19. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  20. # Quick-start development settings - unsuitable for production
  21. # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
  22. # SECURITY WARNING: keep the secret key used in production secret!
  23. #
  24. try:
  25. SECRET_KEY = config['SECRET_KEY']
  26. except KeyError:
  27. chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
  28. s_key = ''.join([random.choice(chars) for n in range(50)])
  29. secret_key_warning = "You need to create a config.py file including a variable config which is a dict with at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key)
  30. raise KeyError(secret_key_warning)
  31. # SECURITY WARNING: don't run with debug turned on in production!
  32. #
  33. DEBUG = False
  34. ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
  35. # Application definition
  36. #
  37. INSTALLED_APPS = [
  38. 'pygal.apps.PygalConfig',
  39. 'themes.apps.ThemesConfig',
  40. 'users.apps.UsersConfig',
  41. #
  42. 'django.contrib.admin',
  43. 'django.contrib.auth',
  44. 'django.contrib.contenttypes',
  45. 'django.contrib.sessions',
  46. 'django.contrib.messages',
  47. 'django.contrib.staticfiles',
  48. ]
  49. MIDDLEWARE = [
  50. 'django.middleware.security.SecurityMiddleware',
  51. 'django.contrib.sessions.middleware.SessionMiddleware',
  52. 'django.middleware.locale.LocaleMiddleware',
  53. 'django.middleware.common.CommonMiddleware',
  54. 'django.middleware.csrf.CsrfViewMiddleware',
  55. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  56. 'django.contrib.messages.middleware.MessageMiddleware',
  57. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  58. 'users.middleware.SettingsMiddleware',
  59. ]
  60. ROOT_URLCONF = 'main.urls'
  61. TEMPLATES = [
  62. {
  63. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  64. 'DIRS': [],
  65. 'APP_DIRS': True,
  66. 'OPTIONS': {
  67. 'context_processors': [
  68. 'django.template.context_processors.debug',
  69. 'django.template.context_processors.request',
  70. 'django.contrib.auth.context_processors.auth',
  71. 'django.contrib.messages.context_processors.messages',
  72. ],
  73. },
  74. },
  75. ]
  76. WSGI_APPLICATION = 'main.wsgi.application'
  77. # Database
  78. # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  79. #
  80. DATABASES = {
  81. 'default': {
  82. 'ENGINE': 'django.db.backends.sqlite3',
  83. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  84. }
  85. }
  86. # Password validation
  87. # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
  88. #
  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. # Search Engine
  104. #
  105. WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
  106. # Internationalization
  107. # https://docs.djangoproject.com/en/2.2/topics/i18n/
  108. #
  109. LANGUAGE_CODE = 'en-us'
  110. LANGUAGES = [
  111. ('en', 'English'),
  112. ('de', 'Deutsch'),
  113. ]
  114. TIME_ZONE = 'UTC'
  115. USE_I18N = True
  116. LOCALE_PATHS = [
  117. os.path.join(BASE_DIR, 'themes', 'locale'),
  118. os.path.join(BASE_DIR, 'users', 'locale'),
  119. os.path.join(BASE_DIR, 'pygal', 'locale'),
  120. ]
  121. USE_L10N = True
  122. USE_TZ = True
  123. # Static files (CSS, JavaScript, Images)
  124. # https://docs.djangoproject.com/en/2.2/howto/static-files/
  125. #
  126. STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
  127. STATIC_URL = '/static/'
  128. MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
  129. MEDIA_URL = '/media/'
  130. # Session parameters
  131. #
  132. SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
  133. SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
  134. PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
  135. # Logging Configuration
  136. #
  137. default_handler = ['console_long'] if DEBUG else ['console']
  138. #
  139. LOGGING = {
  140. 'version': 1,
  141. 'disable_existing_loggers': False,
  142. 'formatters': {
  143. 'short': {
  144. 'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
  145. 'datefmt': '[%d/%b/%Y %H:%M:%S]',
  146. },
  147. 'long': {
  148. 'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  149. File "%(pathname)s", line %(lineno)d, in %(funcName)s
  150. %(asctime)s: %(name)s - %(message)s
  151. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
  152. },
  153. },
  154. 'handlers': {
  155. 'console': {
  156. 'level': 'DEBUG',
  157. 'class': 'logging.StreamHandler',
  158. 'formatter': 'short',
  159. },
  160. 'console_long': {
  161. 'level': 'DEBUG',
  162. 'class': 'logging.StreamHandler',
  163. 'formatter': 'long',
  164. },
  165. },
  166. 'loggers': {
  167. 'AUTH': {
  168. 'handlers': default_handler,
  169. 'level': 'INFO',
  170. 'propagate': False,
  171. },
  172. 'APP': {
  173. 'handlers': default_handler,
  174. 'level': 'INFO',
  175. 'propagate': False,
  176. },
  177. 'CACHING': {
  178. 'handlers': default_handler,
  179. 'level': 'INFO',
  180. 'propagate': False,
  181. },
  182. 'WHOOSH': {
  183. 'handlers': default_handler,
  184. 'level': 'INFO',
  185. 'propagate': False,
  186. },
  187. 'FSTOOLS': {
  188. 'handlers': default_handler,
  189. 'level': 'INFO',
  190. 'propagate': False,
  191. },
  192. 'GEO': {
  193. 'handlers': default_handler,
  194. 'level': 'INFO',
  195. 'propagate': False,
  196. },
  197. },
  198. }
  199. # Other Configuration issues
  200. #
  201. DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
  202. LOGIN_URL = 'users-login'
  203. XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
  204. TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
  205. # App Configuration
  206. #
  207. DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-red')
  208. ITEM_ROOT = config.get('ITEM_ROOT', os.path.join(BASE_DIR, 'data', 'example_data'))
  209. THUMBNAIL_SIZES = config.get('THUMBNAIL_SIZES', [137, 175, 250])
  210. WEBNAIL_SIZES = config.get('WEBNAIL_SIZES', [450, 1100, 1750])