settings.py 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. # Email configuration
  81. # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#email-backend
  82. EMAIL_HOST = 'localhost'
  83. EMAIL_PORT = 25
  84. # If either of these settings is empty, Django won't attempt authentication.
  85. EMAIL_HOST_USER = ''
  86. EMAIL_HOST_PASSWORD = ''
  87. # Default email address to use for various automated correspondence from the site manager(s).
  88. DEFAULT_FROM_EMAIL = 'Forums <%s>' % EMAIL_HOST_USER
  89. # Application definition
  90. AUTH_USER_MODEL = 'misago_users.User'
  91. AUTHENTICATION_BACKENDS = (
  92. 'misago.users.authbackends.MisagoBackend',
  93. )
  94. CSRF_FAILURE_VIEW = 'misago.core.errorpages.csrf_failure'
  95. INSTALLED_APPS = [
  96. # Misago overrides for Django core feature
  97. 'misago',
  98. 'misago.users',
  99. # Django apps
  100. 'django.contrib.admin',
  101. 'django.contrib.auth',
  102. 'django.contrib.contenttypes',
  103. 'django.contrib.humanize',
  104. 'django.contrib.sessions',
  105. 'django.contrib.messages',
  106. 'django.contrib.staticfiles',
  107. # 3rd party apps used by Misago
  108. 'debug_toolbar',
  109. 'crispy_forms',
  110. 'mptt',
  111. 'rest_framework',
  112. # Misago apps
  113. 'misago.admin',
  114. 'misago.acl',
  115. 'misago.core',
  116. 'misago.conf',
  117. 'misago.markup',
  118. 'misago.legal',
  119. 'misago.categories',
  120. 'misago.threads',
  121. 'misago.readtracker',
  122. 'misago.search',
  123. 'misago.faker',
  124. # Utility for moving data from Misago 0.5
  125. 'misago.datamover',
  126. ]
  127. INTERNAL_IPS = ['127.0.0.1']
  128. LOGIN_REDIRECT_URL = 'misago:index'
  129. LOGIN_URL = 'misago:login'
  130. LOGOUT_URL = 'misago:logout'
  131. MIDDLEWARE = [
  132. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  133. 'misago.users.middleware.RealIPMiddleware',
  134. 'misago.core.middleware.frontendcontext.FrontendContextMiddleware',
  135. 'django.middleware.security.SecurityMiddleware',
  136. 'django.contrib.sessions.middleware.SessionMiddleware',
  137. 'django.middleware.common.CommonMiddleware',
  138. 'django.middleware.csrf.CsrfViewMiddleware',
  139. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  140. 'django.contrib.messages.middleware.MessageMiddleware',
  141. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  142. 'misago.users.middleware.UserMiddleware',
  143. 'misago.core.middleware.exceptionhandler.ExceptionHandlerMiddleware',
  144. 'misago.users.middleware.OnlineTrackerMiddleware',
  145. 'misago.admin.middleware.AdminAuthMiddleware',
  146. 'misago.threads.middleware.UnreadThreadsCountMiddleware',
  147. 'misago.core.middleware.threadstore.ThreadStoreMiddleware',
  148. ]
  149. ROOT_URLCONF = '{{ project_name }}.urls'
  150. TEMPLATES = [
  151. {
  152. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  153. 'DIRS': [
  154. os.path.join(BASE_DIR, 'theme', 'templates'),
  155. ],
  156. 'APP_DIRS': True,
  157. 'OPTIONS': {
  158. 'context_processors': [
  159. 'django.template.context_processors.debug',
  160. 'django.template.context_processors.i18n',
  161. 'django.template.context_processors.media',
  162. 'django.template.context_processors.request',
  163. 'django.template.context_processors.static',
  164. 'django.template.context_processors.tz',
  165. 'django.contrib.auth.context_processors.auth',
  166. 'django.contrib.messages.context_processors.messages',
  167. 'misago.core.context_processors.site_address',
  168. 'misago.conf.context_processors.settings',
  169. 'misago.users.context_processors.user_links',
  170. 'misago.legal.context_processors.legal_links',
  171. # Data preloaders
  172. 'misago.conf.context_processors.preload_settings_json',
  173. 'misago.core.context_processors.current_link',
  174. 'misago.markup.context_processors.preload_api_url',
  175. 'misago.threads.context_processors.preload_threads_urls',
  176. 'misago.users.context_processors.preload_user_json',
  177. # Note: keep frontend_context processor last for previous processors
  178. # to be able to expose data UI app via request.frontend_context
  179. 'misago.core.context_processors.frontend_context',
  180. ],
  181. },
  182. },
  183. ]
  184. WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
  185. # Django Crispy Forms
  186. #http://django-crispy-forms.readthedocs.io/en/latest/install.html
  187. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  188. # Django Debug Toolbar
  189. # http://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  190. DEBUG_TOOLBAR_PANELS = (
  191. 'debug_toolbar.panels.versions.VersionsPanel',
  192. 'debug_toolbar.panels.timer.TimerPanel',
  193. 'debug_toolbar.panels.settings.SettingsPanel',
  194. 'debug_toolbar.panels.headers.HeadersPanel',
  195. 'debug_toolbar.panels.request.RequestPanel',
  196. 'debug_toolbar.panels.sql.SQLPanel',
  197. 'misago.acl.panels.MisagoACLPanel',
  198. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  199. 'debug_toolbar.panels.templates.TemplatesPanel',
  200. 'debug_toolbar.panels.cache.CachePanel',
  201. 'debug_toolbar.panels.signals.SignalsPanel',
  202. 'debug_toolbar.panels.logging.LoggingPanel',
  203. )
  204. # Django Rest Framework
  205. # http://www.django-rest-framework.org/api-guide/settings/
  206. REST_FRAMEWORK = {
  207. 'DEFAULT_PERMISSION_CLASSES': (
  208. 'misago.core.rest_permissions.IsAuthenticatedOrReadOnly',
  209. ),
  210. 'DEFAULT_RENDERER_CLASSES': (
  211. 'rest_framework.renderers.JSONRenderer',
  212. ),
  213. 'EXCEPTION_HANDLER': 'misago.core.exceptionhandler.handle_api_exception',
  214. 'UNAUTHENTICATED_USER': 'misago.users.models.AnonymousUser',
  215. 'URL_FORMAT_OVERRIDE': None,
  216. }
  217. # Misago specific settings
  218. # https://misago.readthedocs.io/en/latest/developers/settings.html
  219. # PostgreSQL text search configuration to use in searches
  220. # Defaults to "simple", for list of installed configurations run "\dF" in "psql"
  221. # Standard configs as of PostgreSQL 9.5 are: dutch, english, finnish, french,
  222. # german, hungarian, italian, norwegian, portuguese, romanian, russian, simple,
  223. # spanish, swedish and turkish
  224. # Example on adding custom language can be found here: https://github.com/lemonskyjwt/plpstgrssearch
  225. MISAGO_SEARCH_CONFIG = 'simple'
  226. # Path to directory containing avatar galleries
  227. # Those galleries can be loaded by running loadavatargallery command
  228. MISAGO_AVATAR_GALLERY = os.path.join(BASE_DIR, 'avatargallery')