settings.py 9.4 KB

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