settings.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. ==============================
  2. Configuring Django for Wagtail
  3. ==============================
  4. To install Wagtail completely from scratch, create a new Django project and an app within that project. For instructions on these tasks, see `Writing your first Django app <https://docs.djangoproject.com/en/dev/intro/tutorial01/>`_. Your project directory will look like the following::
  5. myproject/
  6. myproject/
  7. __init__.py
  8. settings.py
  9. urls.py
  10. wsgi.py
  11. myapp/
  12. __init__.py
  13. models.py
  14. tests.py
  15. admin.py
  16. views.py
  17. manage.py
  18. From your app directory, you can safely remove ``admin.py`` and ``views.py``, since Wagtail will provide this functionality for your models. Configuring Django to load Wagtail involves adding modules and variables to ``settings.py`` and URL configuration to ``urls.py``. For a more complete view of what's defined in these files, see `Django Settings <https://docs.djangoproject.com/en/dev/topics/settings/>`__ and `Django URL Dispatcher <https://docs.djangoproject.com/en/dev/topics/http/urls/>`_.
  19. What follows is a settings reference which skips many boilerplate Django settings. If you just want to get your Wagtail install up quickly without fussing with settings at the moment, see :ref:`complete_example_config`.
  20. Middleware (``settings.py``)
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. .. code-block:: python
  23. MIDDLEWARE_CLASSES = [
  24. 'django.contrib.sessions.middleware.SessionMiddleware',
  25. 'django.middleware.common.CommonMiddleware',
  26. 'django.middleware.csrf.CsrfViewMiddleware',
  27. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  28. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  29. 'django.contrib.messages.middleware.MessageMiddleware',
  30. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  31. 'django.middleware.security.SecurityMiddleware',
  32. 'wagtail.wagtailcore.middleware.SiteMiddleware',
  33. 'wagtail.wagtailredirects.middleware.RedirectMiddleware',
  34. ]
  35. Wagtail requires several common Django middleware modules to work and cover basic security. Wagtail provides its own middleware to cover these tasks:
  36. ``SiteMiddleware``
  37. Wagtail routes pre-defined hosts to pages within the Wagtail tree using this middleware.
  38. ``RedirectMiddleware``
  39. Wagtail provides a simple interface for adding arbitrary redirects to your site and this module makes it happen.
  40. Apps (``settings.py``)
  41. ~~~~~~~~~~~~~~~~~~~~~~
  42. .. code-block:: python
  43. INSTALLED_APPS = [
  44. 'myapp', # your own app
  45. 'wagtail.wagtailforms',
  46. 'wagtail.wagtailredirects',
  47. 'wagtail.wagtailembeds',
  48. 'wagtail.wagtailsites',
  49. 'wagtail.wagtailusers',
  50. 'wagtail.wagtailsnippets',
  51. 'wagtail.wagtaildocs',
  52. 'wagtail.wagtailimages',
  53. 'wagtail.wagtailsearch',
  54. 'wagtail.wagtailadmin',
  55. 'wagtail.wagtailcore',
  56. 'taggit',
  57. 'modelcluster',
  58. 'django.contrib.auth',
  59. 'django.contrib.contenttypes',
  60. 'django.contrib.sessions',
  61. 'django.contrib.messages',
  62. 'django.contrib.staticfiles',
  63. ]
  64. Wagtail requires several Django app modules, third-party apps, and defines several apps of its own. Wagtail was built to be modular, so many Wagtail apps can be omitted to suit your needs. Your own app (here ``myapp``) is where you define your models, templates, static assets, template tags, and other custom functionality for your site.
  65. Wagtail Apps
  66. ------------
  67. ``wagtailcore``
  68. The core functionality of Wagtail, such as the ``Page`` class, the Wagtail tree, and model fields.
  69. ``wagtailadmin``
  70. The administration interface for Wagtail, including page edit handlers.
  71. ``wagtaildocs``
  72. The Wagtail document content type.
  73. ``wagtailsnippets``
  74. Editing interface for non-Page models and objects. See :ref:`Snippets`.
  75. ``wagtailusers``
  76. User editing interface.
  77. ``wagtailimages``
  78. The Wagtail image content type.
  79. ``wagtailembeds``
  80. Module governing oEmbed and Embedly content in Wagtail rich text fields. See :ref:`inserting_videos`.
  81. ``wagtailsearch``
  82. Search framework for Page content. See :ref:`search`.
  83. ``wagtailredirects``
  84. Admin interface for creating arbitrary redirects on your site.
  85. ``wagtailforms``
  86. Models for creating forms on your pages and viewing submissions. See :ref:`form_builder`.
  87. Third-Party Apps
  88. ----------------
  89. ``taggit``
  90. Tagging framework for Django. This is used internally within Wagtail for image and document tagging and is available for your own models as well. See :ref:`tagging` for a Wagtail model recipe or the `Taggit Documentation`_.
  91. .. _Taggit Documentation: http://django-taggit.readthedocs.org/en/latest/index.html
  92. ``modelcluster``
  93. Extension of Django ForeignKey relation functionality, which is used in Wagtail pages for on-the-fly related object creation. For more information, see :ref:`inline_panels` or `the django-modelcluster github project page`_.
  94. .. _the django-modelcluster github project page: https://github.com/torchbox/django-modelcluster
  95. Settings Variables (``settings.py``)
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. Wagtail makes use of the following settings, in addition to `Django's core settings <https://docs.djangoproject.com/en/dev/ref/settings/>`__:
  98. Site Name
  99. ---------
  100. .. code-block:: python
  101. WAGTAIL_SITE_NAME = 'Stark Industries Skunkworks'
  102. This is the human-readable name of your Wagtail install which welcomes users upon login to the Wagtail admin.
  103. .. _append_slash:
  104. Append Slash
  105. ------------
  106. .. code-block:: python
  107. # Don't add a trailing slash to Wagtail-served URLs
  108. WAGTAIL_APPEND_SLASH = False
  109. Similar to Django's ``APPEND_SLASH``, this setting controls how Wagtail will handle requests that don't end in a trailing slash.
  110. When ``WAGTAIL_APPEND_SLASH`` is ``True`` (default), requests to Wagtail pages which omit a trailing slash will be redirected by Django's `CommonMiddleware`_ to a URL with a trailing slash.
  111. When ``WAGTAIL_APPEND_SLASH`` is ``False``, requests to Wagtail pages will be served both with and without trailing slashes. Page links generated by Wagtail, however, will not include trailing slashes.
  112. .. note::
  113. If you use the ``False`` setting, keep in mind that serving your pages both with and without slashes may affect search engines' ability to index your site. See `this Google Webmaster Blog post`_ for more details.
  114. .. _commonmiddleware: https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common
  115. .. _this Google Webmaster Blog post: https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
  116. Search
  117. ------
  118. .. code-block:: python
  119. WAGTAILSEARCH_BACKENDS = {
  120. 'default': {
  121. 'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch2',
  122. 'INDEX': 'myapp'
  123. }
  124. }
  125. Define a search backend. For a full explanation, see :ref:`wagtailsearch_backends`.
  126. .. code-block:: python
  127. WAGTAILSEARCH_RESULTS_TEMPLATE = 'myapp/search_results.html'
  128. WAGTAILSEARCH_RESULTS_TEMPLATE_AJAX = 'myapp/includes/search_listing.html'
  129. Override the templates used by the search front-end views.
  130. .. _wagtailsearch_hits_max_age:
  131. .. code-block:: python
  132. WAGTAILSEARCH_HITS_MAX_AGE = 14
  133. Set the number of days (default 7) that search query logs are kept for; these are used to identify popular search terms for :ref:`promoted search results <editors-picks>`. Queries older than this will be removed by the :ref:`search_garbage_collect` command.
  134. Embeds
  135. ------
  136. Wagtail uses the oEmbed standard with a large but not comprehensive number of "providers" (Youtube, Vimeo, etc.). You can also use a different embed backend by providing an Embedly key or replacing the embed backend by writing your own embed finder function.
  137. .. code-block:: python
  138. WAGTAILEMBEDS_EMBED_FINDER = 'myapp.embeds.my_embed_finder_function'
  139. Use a custom embed finder function, which takes a URL and returns a dict with metadata and embeddable HTML. Refer to the ``wagtail.wagtailemebds.embeds`` module source for more information and examples.
  140. .. code-block:: python
  141. # not a working key, get your own!
  142. WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
  143. Providing an API key for the Embedly service will use that as a embed backend, with a more extensive list of providers, as well as analytics and other features. For more information, see `Embedly`_.
  144. .. _Embedly: http://embed.ly/
  145. To use Embedly, you must also install their Python module:
  146. .. code-block:: console
  147. $ pip install embedly
  148. Dashboard
  149. ---------
  150. .. versionadded:: 1.10
  151. .. code-block:: python
  152. WAGTAILADMIN_RECENT_EDITS_LIMIT = 5
  153. This setting lets you change the number of items shown at 'Your most recent edits' on the dashboard.
  154. Images
  155. ------
  156. .. code-block:: python
  157. WAGTAILIMAGES_IMAGE_MODEL = 'myapp.MyImage'
  158. This setting lets you provide your own image model for use in Wagtail, which might extend the built-in ``AbstractImage`` class or replace it entirely.
  159. Maximum Upload size for Images
  160. ------------------------------
  161. .. code-block:: python
  162. WAGTAILIMAGES_MAX_UPLOAD_SIZE = 20 * 1024 * 1024 # i.e. 20MB
  163. This setting lets you override the maximum upload size for images (in bytes). If omitted, Wagtail will fall back to using its 10MB default value.
  164. Password Management
  165. -------------------
  166. .. code-block:: python
  167. WAGTAIL_PASSWORD_MANAGEMENT_ENABLED = True
  168. This specifies whether users are allowed to change their passwords (enabled by default).
  169. .. code-block:: python
  170. WAGTAIL_PASSWORD_RESET_ENABLED = True
  171. This specifies whether users are allowed to reset their passwords. Defaults to the same as ``WAGTAIL_PASSWORD_MANAGEMENT_ENABLED``.
  172. Email Notifications
  173. -------------------
  174. .. code-block:: python
  175. WAGTAILADMIN_NOTIFICATION_FROM_EMAIL = 'wagtail@myhost.io'
  176. Wagtail sends email notifications when content is submitted for moderation, and when the content is accepted or rejected. This setting lets you pick which email address these automatic notifications will come from. If omitted, Django will fall back to using the ``DEFAULT_FROM_EMAIL`` variable if set, and ``webmaster@localhost`` if not.
  177. .. _email_notifications_format:
  178. Email Notifications format
  179. --------------------------
  180. .. code-block:: python
  181. WAGTAILADMIN_NOTIFICATION_USE_HTML = True
  182. Notification emails are sent in `text/plain` by default, change this to use HTML formatting.
  183. .. _update_notifications:
  184. Wagtail update notifications
  185. ----------------------------
  186. .. code-block:: python
  187. WAGTAIL_ENABLE_UPDATE_CHECK = True
  188. For admins only, Wagtail performs a check on the dashboard to see if newer releases are available. This also provides the Wagtail team with the hostname of your Wagtail site. If you'd rather not receive update notifications, or if you'd like your site to remain unknown, you can disable it with this setting.
  189. Private Pages
  190. -------------
  191. .. code-block:: python
  192. PASSWORD_REQUIRED_TEMPLATE = 'myapp/password_required.html'
  193. This is the path to the Django template which will be used to display the "password required" form when a user accesses a private page. For more details, see the :ref:`private_pages` documentation.
  194. Case-Insensitive Tags
  195. ---------------------
  196. .. code-block:: python
  197. TAGGIT_CASE_INSENSITIVE = True
  198. Tags are case-sensitive by default ('music' and 'Music' are treated as distinct tags). In many cases the reverse behaviour is preferable.
  199. Multi-word tags
  200. ---------------
  201. .. versionadded:: 1.10
  202. .. code-block:: python
  203. TAG_SPACES_ALLOWED = False
  204. Tags can only consist of a single word, no spaces allowed. The default setting is ``True`` (spaces in tags are allowed).
  205. Unicode Page Slugs
  206. ------------------
  207. .. code-block:: python
  208. WAGTAIL_ALLOW_UNICODE_SLUGS = True
  209. By default, page slugs can contain any alphanumeric characters, including non-Latin alphabets (except on Django 1.8, where only ASCII characters are supported). Set this to False to limit slugs to ASCII characters.
  210. .. _WAGTAIL_AUTO_UPDATE_PREVIEW:
  211. Auto update preview
  212. -------------------
  213. .. versionadded:: 1.10
  214. .. code-block:: python
  215. WAGTAIL_AUTO_UPDATE_PREVIEW = False
  216. When enabled, data from an edited page is automatically sent to the server
  217. on each change, even without saving. That way, users don’t have to click on
  218. “Preview” to update the content of the preview page. However, the preview page
  219. tab is not refreshed automatically, users have to do it manually.
  220. This behaviour is disabled by default.
  221. Custom User Edit Forms
  222. ----------------------
  223. See :doc:`/advanced_topics/customisation/custom_user_models`.
  224. .. code-block:: python
  225. WAGTAIL_USER_EDIT_FORM = 'users.forms.CustomUserEditForm'
  226. Allows the default ``UserEditForm`` class to be overridden with a custom form when
  227. a custom user model is being used and extra fields are required in the user edit form.
  228. .. code-block:: python
  229. WAGTAIL_USER_CREATION_FORM = 'users.forms.CustomUserCreationForm'
  230. Allows the default ``UserCreationForm`` class to be overridden with a custom form when
  231. a custom user model is being used and extra fields are required in the user creation form.
  232. .. code-block:: python
  233. WAGTAIL_USER_CUSTOM_FIELDS = ['country']
  234. A list of the extra custom fields to be appended to the default list.
  235. Usage for images, documents and snippets
  236. ----------------------------------------
  237. .. code-block:: python
  238. WAGTAIL_USAGE_COUNT_ENABLED = True
  239. When enabled Wagtail shows where a particular image, document or snippet is being used on your site (disabled by default). A link will appear on the edit page showing you which pages they have been used on.
  240. .. note::
  241. The usage count only applies to direct (database) references. Using documents, images and snippets within StreamFields or rich text fields will not be taken into account.
  242. Date and DateTime inputs
  243. ------------------------
  244. .. code-block:: python
  245. WAGTAIL_DATE_FORMAT = '%d.%m.%Y.'
  246. WAGTAIL_DATETIME_FORMAT = '%d.%m.%Y. %H:%M'
  247. Specifies the date and datetime format to be used in input fields in the Wagtail admin. The format is specified in `Python datetime module syntax <https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior>`_, and must be one of the recognised formats listed in the ``DATE_INPUT_FORMATS`` or ``DATETIME_INPUT_FORMATS`` setting respectively (see `DATE_INPUT_FORMATS <https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-DATE_INPUT_FORMATS>`_).
  248. .. _WAGTAILADMIN_PERMITTED_LANGUAGES:
  249. Admin languages
  250. ---------------
  251. .. versionadded:: 1.10
  252. Users can choose between several languages for the admin interface
  253. in the account settings. The list of languages is by default all the available
  254. languages in Wagtail. To change it, set ``WAGTAILADMIN_PERMITTED_LANGUAGES``:
  255. .. code-block:: python
  256. WAGTAILADMIN_PERMITTED_LANGUAGES = [('en', 'English'),
  257. ('pt', 'Portuguese')]
  258. Since the syntax is the same as Django ``LANGUAGES``, you can do this so users
  259. can only choose between front office languages:
  260. .. code-block:: python
  261. LANGUAGES = WAGTAILADMIN_PERMITTED_LANGUAGES = [('en', 'English'),
  262. ('pt', 'Portuguese')]
  263. URL Patterns
  264. ~~~~~~~~~~~~
  265. .. code-block:: python
  266. from django.contrib import admin
  267. from wagtail.wagtailcore import urls as wagtail_urls
  268. from wagtail.wagtailadmin import urls as wagtailadmin_urls
  269. from wagtail.wagtaildocs import urls as wagtaildocs_urls
  270. from wagtail.wagtailsearch import urls as wagtailsearch_urls
  271. urlpatterns = [
  272. url(r'^django-admin/', include(admin.site.urls)),
  273. url(r'^admin/', include(wagtailadmin_urls)),
  274. url(r'^search/', include(wagtailsearch_urls)),
  275. url(r'^documents/', include(wagtaildocs_urls)),
  276. # Optional URL for including your own vanilla Django urls/views
  277. url(r'', include('myapp.urls')),
  278. # For anything not caught by a more specific rule above, hand over to
  279. # Wagtail's serving mechanism
  280. url(r'', include(wagtail_urls)),
  281. ]
  282. This block of code for your project's ``urls.py`` does a few things:
  283. * Load the vanilla Django admin interface to ``/django-admin/``
  284. * Load the Wagtail admin and its various apps
  285. * Dispatch any vanilla Django apps you're using other than Wagtail which require their own URL configuration (this is optional, since Wagtail might be all you need)
  286. * Lets Wagtail handle any further URL dispatching.
  287. That's not everything you might want to include in your project's URL configuration, but it's what's necessary for Wagtail to flourish.
  288. .. _complete_example_config:
  289. Ready to Use Example Configuration Files
  290. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  291. These two files should reside in your project directory (``myproject/myproject/``).
  292. ``settings.py``
  293. ---------------
  294. .. code-block:: python
  295. import os
  296. PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  297. BASE_DIR = os.path.dirname(PROJECT_DIR)
  298. DEBUG = True
  299. # Application definition
  300. INSTALLED_APPS = [
  301. 'myapp',
  302. 'wagtail.wagtailforms',
  303. 'wagtail.wagtailredirects',
  304. 'wagtail.wagtailembeds',
  305. 'wagtail.wagtailsites',
  306. 'wagtail.wagtailusers',
  307. 'wagtail.wagtailsnippets',
  308. 'wagtail.wagtaildocs',
  309. 'wagtail.wagtailimages',
  310. 'wagtail.wagtailsearch',
  311. 'wagtail.wagtailadmin',
  312. 'wagtail.wagtailcore',
  313. 'taggit',
  314. 'modelcluster',
  315. 'django.contrib.auth',
  316. 'django.contrib.contenttypes',
  317. 'django.contrib.sessions',
  318. 'django.contrib.messages',
  319. 'django.contrib.staticfiles',
  320. ]
  321. MIDDLEWARE_CLASSES = [
  322. 'django.contrib.sessions.middleware.SessionMiddleware',
  323. 'django.middleware.common.CommonMiddleware',
  324. 'django.middleware.csrf.CsrfViewMiddleware',
  325. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  326. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  327. 'django.contrib.messages.middleware.MessageMiddleware',
  328. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  329. 'django.middleware.security.SecurityMiddleware',
  330. 'wagtail.wagtailcore.middleware.SiteMiddleware',
  331. 'wagtail.wagtailredirects.middleware.RedirectMiddleware',
  332. ]
  333. ROOT_URLCONF = 'myproject.urls'
  334. TEMPLATES = [
  335. {
  336. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  337. 'DIRS': [
  338. os.path.join(PROJECT_DIR, 'templates'),
  339. ],
  340. 'APP_DIRS': True,
  341. 'OPTIONS': {
  342. 'context_processors': [
  343. 'django.template.context_processors.debug',
  344. 'django.template.context_processors.request',
  345. 'django.contrib.auth.context_processors.auth',
  346. 'django.contrib.messages.context_processors.messages',
  347. ],
  348. },
  349. },
  350. ]
  351. WSGI_APPLICATION = 'wagtaildemo.wsgi.application'
  352. # Database
  353. DATABASES = {
  354. 'default': {
  355. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  356. 'NAME': 'myprojectdb',
  357. 'USER': 'postgres',
  358. 'PASSWORD': '',
  359. 'HOST': '', # Set to empty string for localhost.
  360. 'PORT': '', # Set to empty string for default.
  361. 'CONN_MAX_AGE': 600, # number of seconds database connections should persist for
  362. }
  363. }
  364. # Internationalization
  365. LANGUAGE_CODE = 'en-us'
  366. TIME_ZONE = 'UTC'
  367. USE_I18N = True
  368. USE_L10N = True
  369. USE_TZ = True
  370. # Static files (CSS, JavaScript, Images)
  371. STATICFILES_FINDERS = [
  372. 'django.contrib.staticfiles.finders.FileSystemFinder',
  373. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  374. ]
  375. STATICFILES_DIRS = [
  376. os.path.join(PROJECT_DIR, 'static'),
  377. ]
  378. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  379. STATIC_URL = '/static/'
  380. MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  381. MEDIA_URL = '/media/'
  382. ADMINS = [
  383. # ('Your Name', 'your_email@example.com'),
  384. ]
  385. MANAGERS = ADMINS
  386. # Default to dummy email backend. Configure dev/production/local backend
  387. # as per https://docs.djangoproject.com/en/dev/topics/email/#email-backends
  388. EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
  389. # Hosts/domain names that are valid for this site; required if DEBUG is False
  390. ALLOWED_HOSTS = []
  391. # Make this unique, and don't share it with anybody.
  392. SECRET_KEY = 'change-me'
  393. EMAIL_SUBJECT_PREFIX = '[Wagtail] '
  394. INTERNAL_IPS = ('127.0.0.1', '10.0.2.2')
  395. # A sample logging configuration. The only tangible logging
  396. # performed by this configuration is to send an email to
  397. # the site admins on every HTTP 500 error when DEBUG=False.
  398. # See http://docs.djangoproject.com/en/dev/topics/logging for
  399. # more details on how to customize your logging configuration.
  400. LOGGING = {
  401. 'version': 1,
  402. 'disable_existing_loggers': False,
  403. 'filters': {
  404. 'require_debug_false': {
  405. '()': 'django.utils.log.RequireDebugFalse'
  406. }
  407. },
  408. 'handlers': {
  409. 'mail_admins': {
  410. 'level': 'ERROR',
  411. 'filters': ['require_debug_false'],
  412. 'class': 'django.utils.log.AdminEmailHandler'
  413. }
  414. },
  415. 'loggers': {
  416. 'django.request': {
  417. 'handlers': ['mail_admins'],
  418. 'level': 'ERROR',
  419. 'propagate': True,
  420. },
  421. }
  422. }
  423. # WAGTAIL SETTINGS
  424. # This is the human-readable name of your Wagtail install
  425. # which welcomes users upon login to the Wagtail admin.
  426. WAGTAIL_SITE_NAME = 'My Project'
  427. # Override the search results template for wagtailsearch
  428. # WAGTAILSEARCH_RESULTS_TEMPLATE = 'myapp/search_results.html'
  429. # WAGTAILSEARCH_RESULTS_TEMPLATE_AJAX = 'myapp/includes/search_listing.html'
  430. # Replace the search backend
  431. #WAGTAILSEARCH_BACKENDS = {
  432. # 'default': {
  433. # 'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch2',
  434. # 'INDEX': 'myapp'
  435. # }
  436. #}
  437. # Wagtail email notifications from address
  438. # WAGTAILADMIN_NOTIFICATION_FROM_EMAIL = 'wagtail@myhost.io'
  439. # Wagtail email notification format
  440. # WAGTAILADMIN_NOTIFICATION_USE_HTML = True
  441. # If you want to use Embedly for embeds, supply a key
  442. # (this key doesn't work, get your own!)
  443. # WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830'
  444. # Reverse the default case-sensitive handling of tags
  445. TAGGIT_CASE_INSENSITIVE = True
  446. ``urls.py``
  447. -----------
  448. .. code-block:: python
  449. from django.conf.urls import include, url
  450. from django.conf.urls.static import static
  451. from django.views.generic.base import RedirectView
  452. from django.contrib import admin
  453. from django.conf import settings
  454. import os.path
  455. from wagtail.wagtailcore import urls as wagtail_urls
  456. from wagtail.wagtailadmin import urls as wagtailadmin_urls
  457. from wagtail.wagtaildocs import urls as wagtaildocs_urls
  458. from wagtail.wagtailsearch import urls as wagtailsearch_urls
  459. urlpatterns = [
  460. url(r'^django-admin/', include(admin.site.urls)),
  461. url(r'^admin/', include(wagtailadmin_urls)),
  462. url(r'^search/', include(wagtailsearch_urls)),
  463. url(r'^documents/', include(wagtaildocs_urls)),
  464. # For anything not caught by a more specific rule above, hand over to
  465. # Wagtail's serving mechanism
  466. url(r'', include(wagtail_urls)),
  467. ]
  468. if settings.DEBUG:
  469. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  470. urlpatterns += staticfiles_urlpatterns() # tell gunicorn where static files are in dev mode
  471. urlpatterns += static(settings.MEDIA_URL + 'images/', document_root=os.path.join(settings.MEDIA_ROOT, 'images'))
  472. urlpatterns += [
  473. url(r'^favicon\.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'myapp/images/favicon.ico'))
  474. ]