settings.py 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. """
  2. Django settings for {{ project_name }} project.
  3. Generated by 'django-admin startproject' using Django {{ django_version }}.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '{{ secret_key }}'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = []
  19. # Database
  20. # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#databases
  21. DATABASES = {
  22. 'default': {
  23. # Misago requires PostgreSQL to run
  24. 'ENGINE': 'django.db.backends.postgresql',
  25. 'NAME': '',
  26. 'USER': '',
  27. 'HOST': 'localhost',
  28. 'PORT': 5432,
  29. }
  30. }
  31. # Caching
  32. # https://docs.djangoproject.com/en/{{ docs_version }}/topics/cache/#setting-up-the-cache
  33. CACHES = {
  34. 'default': {
  35. # Misago doesn't run well with LocMemCache in production environments
  36. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  37. }
  38. }
  39. # Password validation
  40. # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators
  41. AUTH_PASSWORD_VALIDATORS = [
  42. {
  43. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  44. },
  45. {
  46. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  47. },
  48. {
  49. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  50. },
  51. {
  52. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  53. },
  54. ]
  55. # Internationalization
  56. # https://docs.djangoproject.com/en/{{ docs_version }}/topics/i18n/
  57. LANGUAGE_CODE = 'en-us'
  58. TIME_ZONE = 'UTC'
  59. USE_I18N = True
  60. USE_L10N = True
  61. USE_TZ = True
  62. # Static files (CSS, JavaScript, Images)
  63. # https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
  64. STATIC_URL = '/static/'
  65. # User uploads (Avatars, Attachments, files uploaded in other Django apps, ect.)
  66. # https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
  67. MEDIA_URL = '/media/'
  68. # The absolute path to the directory where collectstatic will collect static files for deployment.
  69. # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#static-root
  70. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  71. # Absolute filesystem path to the directory that will hold user-uploaded files.
  72. # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#media-root
  73. MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  74. # This setting defines the additional locations the staticfiles app will traverse if the FileSystemFinder finder
  75. # is enabled, e.g. if you use the collectstatic or findstatic management command or use the static file serving view.
  76. # https://docs.djangoproject.com/en/1.10/ref/settings/#staticfiles-dirs
  77. STATICFILES_DIRS = (
  78. os.path.join(BASE_DIR, 'theme', 'static'),
  79. )
  80. # Application definition
  81. AUTH_USER_MODEL = 'misago_users.User'
  82. AUTHENTICATION_BACKENDS = (
  83. 'misago.users.authbackends.MisagoBackend',
  84. )
  85. CSRF_FAILURE_VIEW = 'misago.core.errorpages.csrf_failure'
  86. INSTALLED_APPS = [
  87. # Misago overrides for Django core feature
  88. 'misago',
  89. 'misago.users',
  90. # Django apps
  91. 'django.contrib.admin',
  92. 'django.contrib.auth',
  93. 'django.contrib.contenttypes',
  94. 'django.contrib.humanize',
  95. 'django.contrib.sessions',
  96. 'django.contrib.messages',
  97. 'django.contrib.staticfiles',
  98. # 3rd party apps used by Misago
  99. 'debug_toolbar',
  100. 'crispy_forms',
  101. 'mptt',
  102. 'rest_framework',
  103. # Misago apps
  104. 'misago.admin',
  105. 'misago.acl',
  106. 'misago.core',
  107. 'misago.conf',
  108. 'misago.markup',
  109. 'misago.legal',
  110. 'misago.categories',
  111. 'misago.threads',
  112. 'misago.readtracker',
  113. 'misago.search',
  114. 'misago.faker',
  115. # Utility for moving data from Misago 0.5
  116. 'misago.datamover',
  117. ]
  118. INTERNAL_IPS = ['127.0.0.1']
  119. LOGIN_REDIRECT_URL = 'misago:index'
  120. LOGIN_URL = 'misago:login'
  121. LOGOUT_URL = 'misago:logout'
  122. MIDDLEWARE = [
  123. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  124. 'misago.users.middleware.RealIPMiddleware',
  125. 'misago.core.middleware.frontendcontext.FrontendContextMiddleware',
  126. 'django.middleware.security.SecurityMiddleware',
  127. 'django.contrib.sessions.middleware.SessionMiddleware',
  128. 'django.middleware.common.CommonMiddleware',
  129. 'django.middleware.csrf.CsrfViewMiddleware',
  130. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  131. 'django.contrib.messages.middleware.MessageMiddleware',
  132. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  133. 'misago.users.middleware.UserMiddleware',
  134. 'misago.core.middleware.exceptionhandler.ExceptionHandlerMiddleware',
  135. 'misago.users.middleware.OnlineTrackerMiddleware',
  136. 'misago.admin.middleware.AdminAuthMiddleware',
  137. 'misago.threads.middleware.UnreadThreadsCountMiddleware',
  138. 'misago.core.middleware.threadstore.ThreadStoreMiddleware',
  139. ]
  140. ROOT_URLCONF = '{{ project_name }}.urls'
  141. TEMPLATES = [
  142. {
  143. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  144. 'DIRS': [
  145. os.path.join(BASE_DIR, 'theme', 'templates'),
  146. ],
  147. 'APP_DIRS': True,
  148. 'OPTIONS': {
  149. 'context_processors': [
  150. 'django.template.context_processors.debug',
  151. 'django.template.context_processors.i18n',
  152. 'django.template.context_processors.media',
  153. 'django.template.context_processors.request',
  154. 'django.template.context_processors.static',
  155. 'django.template.context_processors.tz',
  156. 'django.contrib.auth.context_processors.auth',
  157. 'django.contrib.messages.context_processors.messages',
  158. 'misago.core.context_processors.site_address',
  159. 'misago.conf.context_processors.settings',
  160. 'misago.users.context_processors.user_links',
  161. 'misago.legal.context_processors.legal_links',
  162. # Data preloaders
  163. 'misago.conf.context_processors.preload_settings_json',
  164. 'misago.core.context_processors.current_link',
  165. 'misago.markup.context_processors.preload_api_url',
  166. 'misago.threads.context_processors.preload_threads_urls',
  167. 'misago.users.context_processors.preload_user_json',
  168. # Note: keep frontend_context processor last for previous processors
  169. # to be able to expose data UI app via request.frontend_context
  170. 'misago.core.context_processors.frontend_context',
  171. ],
  172. },
  173. },
  174. ]
  175. WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
  176. # Django Crispy Forms
  177. #http://django-crispy-forms.readthedocs.io/en/latest/install.html
  178. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  179. # Django Debug Toolbar
  180. # http://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  181. DEBUG_TOOLBAR_PANELS = (
  182. 'debug_toolbar.panels.versions.VersionsPanel',
  183. 'debug_toolbar.panels.timer.TimerPanel',
  184. 'debug_toolbar.panels.settings.SettingsPanel',
  185. 'debug_toolbar.panels.headers.HeadersPanel',
  186. 'debug_toolbar.panels.request.RequestPanel',
  187. 'debug_toolbar.panels.sql.SQLPanel',
  188. 'misago.acl.panels.MisagoACLPanel',
  189. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  190. 'debug_toolbar.panels.templates.TemplatesPanel',
  191. 'debug_toolbar.panels.cache.CachePanel',
  192. 'debug_toolbar.panels.signals.SignalsPanel',
  193. 'debug_toolbar.panels.logging.LoggingPanel',
  194. )
  195. # Django Rest Framework
  196. # http://www.django-rest-framework.org/api-guide/settings/
  197. REST_FRAMEWORK = {
  198. 'DEFAULT_PERMISSION_CLASSES': (
  199. 'misago.core.rest_permissions.IsAuthenticatedOrReadOnly',
  200. ),
  201. 'DEFAULT_RENDERER_CLASSES': (
  202. 'rest_framework.renderers.JSONRenderer',
  203. ),
  204. 'EXCEPTION_HANDLER': 'misago.core.exceptionhandler.handle_api_exception',
  205. 'UNAUTHENTICATED_USER': 'misago.users.models.AnonymousUser',
  206. 'URL_FORMAT_OVERRIDE': None,
  207. }
  208. # Misago specific settings
  209. # https://misago.readthedocs.io/en/latest/developers/settings.html
  210. # PostgreSQL text search configuration to use in searches
  211. # Defaults to "simple", for list of installed configurations run "\dF" in "psql"
  212. # Standard configs as of PostgreSQL 9.5 are: dutch, english, finnish, french,
  213. # german, hungarian, italian, norwegian, portuguese, romanian, russian, simple,
  214. # spanish, swedish and turkish
  215. # Example on adding custom language can be found here: https://github.com/lemonskyjwt/plpstgrssearch
  216. MISAGO_SEARCH_CONFIG = 'simple'
  217. # Path to directory containing avatar galleries
  218. # Those galleries can be loaded by running loadavatargallery command
  219. MISAGO_AVATAR_GALLERY = os.path.join(BASE_DIR, 'avatargallery')