settings.py 11 KB

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