settings.py 9.6 KB

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