settings.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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 export their own data?
  103. # This may take some pressure from site administrators handling data export or access requests made
  104. # by users exerting rights granted to them by GDPR.
  105. MISAGO_ENABLE_EXPORT_OWN_DATA = True
  106. # Allow users to delete their own accounts?
  107. # Providing such feature is required by EU law from entities that process europeans personal data.
  108. MISAGO_ENABLE_DELETE_OWN_ACCOUNT = True
  109. # Application definition
  110. AUTH_USER_MODEL = 'misago_users.User'
  111. AUTHENTICATION_BACKENDS = [
  112. 'misago.users.authbackends.MisagoBackend',
  113. ]
  114. CSRF_FAILURE_VIEW = 'misago.core.errorpages.csrf_failure'
  115. INSTALLED_APPS = [
  116. # Misago overrides for Django core feature
  117. 'misago',
  118. 'misago.users',
  119. # Django apps
  120. 'django.contrib.admin',
  121. 'django.contrib.auth',
  122. 'django.contrib.contenttypes',
  123. 'django.contrib.postgres',
  124. 'django.contrib.humanize',
  125. 'django.contrib.sessions',
  126. 'django.contrib.messages',
  127. 'django.contrib.staticfiles',
  128. # 3rd party apps used by Misago
  129. 'debug_toolbar',
  130. 'crispy_forms',
  131. 'mptt',
  132. 'rest_framework',
  133. 'social_django',
  134. # Misago apps
  135. 'misago.admin',
  136. 'misago.acl',
  137. 'misago.core',
  138. 'misago.conf',
  139. 'misago.markup',
  140. 'misago.legal',
  141. 'misago.categories',
  142. 'misago.threads',
  143. 'misago.readtracker',
  144. 'misago.search',
  145. 'misago.faker',
  146. ]
  147. INTERNAL_IPS = [
  148. '127.0.0.1'
  149. ]
  150. LOGIN_REDIRECT_URL = 'misago:index'
  151. LOGIN_URL = 'misago:login'
  152. LOGOUT_URL = 'misago:logout'
  153. MIDDLEWARE = [
  154. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  155. 'misago.users.middleware.RealIPMiddleware',
  156. 'misago.core.middleware.frontendcontext.FrontendContextMiddleware',
  157. 'django.middleware.security.SecurityMiddleware',
  158. 'django.contrib.sessions.middleware.SessionMiddleware',
  159. 'django.middleware.common.CommonMiddleware',
  160. 'django.middleware.csrf.CsrfViewMiddleware',
  161. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  162. 'django.contrib.messages.middleware.MessageMiddleware',
  163. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  164. 'misago.users.middleware.UserMiddleware',
  165. 'misago.core.middleware.exceptionhandler.ExceptionHandlerMiddleware',
  166. 'misago.users.middleware.OnlineTrackerMiddleware',
  167. 'misago.admin.middleware.AdminAuthMiddleware',
  168. 'misago.threads.middleware.UnreadThreadsCountMiddleware',
  169. 'misago.core.middleware.threadstore.ThreadStoreMiddleware',
  170. ]
  171. ROOT_URLCONF = '{{ project_name }}.urls'
  172. SOCIAL_AUTH_PIPELINE = (
  173. # Steps required by social pipeline to work - don't delete those!
  174. 'social_core.pipeline.social_auth.social_details',
  175. 'social_core.pipeline.social_auth.social_uid',
  176. 'social_core.pipeline.social_auth.social_user',
  177. # Uncomment next line to let your users to associate their old forum account with social one.
  178. # 'misago.users.social.pipeline.associate_by_email',
  179. # Those steps make sure banned users may not join your site or use banned name or email.
  180. 'misago.users.social.pipeline.validate_ip_not_banned',
  181. 'misago.users.social.pipeline.validate_user_not_banned',
  182. # Reads user data received from social site and tries to create valid and available username
  183. # Required if you want automatic account creation to work. Otherwhise optional.
  184. 'misago.users.social.pipeline.get_username',
  185. # Uncomment next line to enable automatic account creation if data from social site is valid
  186. # and get_username found valid name for new user account:
  187. # 'misago.users.social.pipeline.create_user',
  188. # This step asks user to complete simple, pre filled registration form containing username,
  189. # email, legal note if you remove it without adding custom one, users will have no fallback
  190. # for joining your site using their social account.
  191. 'misago.users.social.pipeline.create_user_with_form',
  192. # Steps finalizing social authentication flow - don't delete those!
  193. 'social_core.pipeline.social_auth.associate_user',
  194. 'social_core.pipeline.social_auth.load_extra_data',
  195. 'misago.users.social.pipeline.require_activation',
  196. )
  197. SOCIAL_AUTH_POSTGRES_JSONFIELD = True
  198. TEMPLATES = [
  199. {
  200. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  201. 'DIRS': [
  202. os.path.join(BASE_DIR, 'theme', 'templates'),
  203. ],
  204. 'APP_DIRS': True,
  205. 'OPTIONS': {
  206. 'context_processors': [
  207. 'django.template.context_processors.debug',
  208. 'django.template.context_processors.i18n',
  209. 'django.template.context_processors.media',
  210. 'django.template.context_processors.request',
  211. 'django.template.context_processors.static',
  212. 'django.template.context_processors.tz',
  213. 'django.contrib.auth.context_processors.auth',
  214. 'django.contrib.messages.context_processors.messages',
  215. 'misago.core.context_processors.site_address',
  216. 'misago.core.context_processors.momentjs_locale',
  217. 'misago.conf.context_processors.settings',
  218. 'misago.search.context_processors.search_providers',
  219. 'misago.users.context_processors.user_links',
  220. 'misago.legal.context_processors.legal_links',
  221. # Data preloaders
  222. 'misago.conf.context_processors.preload_settings_json',
  223. 'misago.core.context_processors.current_link',
  224. 'misago.markup.context_processors.preload_api_url',
  225. 'misago.threads.context_processors.preload_threads_urls',
  226. 'misago.users.context_processors.preload_user_json',
  227. # Note: keep frontend_context processor last for previous processors
  228. # to be able to expose data UI app via request.frontend_context
  229. 'misago.core.context_processors.frontend_context',
  230. ],
  231. },
  232. },
  233. ]
  234. WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
  235. # Django Crispy Forms
  236. #http://django-crispy-forms.readthedocs.io/en/latest/install.html
  237. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  238. # Django Debug Toolbar
  239. # http://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  240. DEBUG_TOOLBAR_PANELS = [
  241. 'debug_toolbar.panels.versions.VersionsPanel',
  242. 'debug_toolbar.panels.timer.TimerPanel',
  243. 'debug_toolbar.panels.settings.SettingsPanel',
  244. 'debug_toolbar.panels.headers.HeadersPanel',
  245. 'debug_toolbar.panels.request.RequestPanel',
  246. 'debug_toolbar.panels.sql.SQLPanel',
  247. 'misago.acl.panels.MisagoACLPanel',
  248. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  249. 'debug_toolbar.panels.templates.TemplatesPanel',
  250. 'debug_toolbar.panels.cache.CachePanel',
  251. 'debug_toolbar.panels.signals.SignalsPanel',
  252. 'debug_toolbar.panels.logging.LoggingPanel',
  253. ]
  254. # Django Rest Framework
  255. # http://www.django-rest-framework.org/api-guide/settings/
  256. REST_FRAMEWORK = {
  257. 'DEFAULT_PERMISSION_CLASSES': [
  258. 'misago.core.rest_permissions.IsAuthenticatedOrReadOnly',
  259. ],
  260. 'DEFAULT_RENDERER_CLASSES': [
  261. 'rest_framework.renderers.JSONRenderer',
  262. ],
  263. 'EXCEPTION_HANDLER': 'misago.core.exceptionhandler.handle_api_exception',
  264. 'UNAUTHENTICATED_USER': 'misago.users.models.AnonymousUser',
  265. 'URL_FORMAT_OVERRIDE': None,
  266. }
  267. # Misago specific settings
  268. # https://misago.readthedocs.io/en/latest/developers/settings.html
  269. # Complete HTTP address to your Misago site homepage. Misago relies on this address to create
  270. # links in e-mails that are sent to site users.
  271. # On Misago admin panel home page you will find a message telling you if you have entered the
  272. # correct value, or what value is correct in case you've didn't.
  273. MISAGO_ADDRESS = 'http://my-misago-site.com/'
  274. # PostgreSQL text search configuration to use in searches
  275. # Defaults to "simple", for list of installed configurations run "\dF" in "psql"
  276. # Standard configs as of PostgreSQL 9.5 are: dutch, english, finnish, french,
  277. # german, hungarian, italian, norwegian, portuguese, romanian, russian, simple,
  278. # spanish, swedish and turkish
  279. # Example on adding custom language can be found here: https://github.com/lemonskyjwt/plpstgrssearch
  280. MISAGO_SEARCH_CONFIG = 'simple'
  281. # Path to directory containing avatar galleries
  282. # Those galleries can be loaded by running loadavatargallery command
  283. MISAGO_AVATAR_GALLERY = os.path.join(BASE_DIR, 'avatargallery')
  284. # Specifies the number of days that IP addresses are stored in the database before removing.
  285. # Change this setting to None to never remove old IP addresses.
  286. MISAGO_IP_STORE_TIME = 50
  287. # Profile fields
  288. MISAGO_PROFILE_FIELDS = [
  289. {
  290. 'name': _("Personal"),
  291. 'fields': [
  292. 'misago.users.profilefields.default.RealNameField',
  293. 'misago.users.profilefields.default.GenderField',
  294. 'misago.users.profilefields.default.BioField',
  295. 'misago.users.profilefields.default.LocationField',
  296. ],
  297. },
  298. {
  299. 'name': _("Contact"),
  300. 'fields': [
  301. 'misago.users.profilefields.default.TwitterHandleField',
  302. 'misago.users.profilefields.default.SkypeIdField',
  303. 'misago.users.profilefields.default.WebsiteField',
  304. ],
  305. },
  306. {
  307. 'name': _("IP address"),
  308. 'fields': [
  309. 'misago.users.profilefields.default.JoinIpField',
  310. ],
  311. },
  312. ]