repos

blog.bythewood.me-wagtail

mirror archived upstream

Self-hostable blog for developers built on Wagtail and Django, with webpack, Bootstrap, and CodeMirror.

blogbootstrapdjangodockerhandcodedpythonself-hostedwagtailwebpack

4.4 KB · 169 lines · Python Raw History
  1import os
  2from pathlib import Path
  3
  4from django.contrib.messages import constants as messages
  5
  6
  7# Build paths inside the project like this: BASE_DIR / 'subdir'.
  8BASE_DIR = Path(__file__).resolve().parent.parent.parent
  9
 10
 11# Models
 12# https://docs.djangoproject.com/en/3.0/ref/settings/#models
 13
 14INSTALLED_APPS = [
 15    'django.contrib.admin',
 16    'django.contrib.auth',
 17    'django.contrib.contenttypes',
 18    'django.contrib.sessions',
 19    'django.contrib.messages',
 20    'django.contrib.staticfiles',
 21    'django.contrib.sitemaps',
 22
 23    'wagtail_modeladmin',
 24    "wagtail.contrib.routable_page",
 25    'wagtail.contrib.redirects',
 26    'wagtail.embeds',
 27    'wagtail.sites',
 28    'wagtail.users',
 29    'wagtail.snippets',
 30    'wagtail.documents',
 31    'wagtail.images',
 32    'wagtail.search',
 33    'wagtail.admin',
 34    'wagtail',
 35
 36    'taggit',
 37    'modelcluster',
 38
 39    'admin',
 40    'accounts',
 41    'pages',
 42    'scheduler',
 43    'mail',
 44]
 45
 46MIDDLEWARE = [
 47    'django.middleware.security.SecurityMiddleware',
 48
 49    'wagtail.contrib.redirects.middleware.RedirectMiddleware',
 50    'whitenoise.middleware.WhiteNoiseMiddleware',
 51
 52    'django.contrib.sessions.middleware.SessionMiddleware',
 53    'django.middleware.common.CommonMiddleware',
 54    'django.middleware.csrf.CsrfViewMiddleware',
 55    'django.contrib.auth.middleware.AuthenticationMiddleware',
 56    'django.contrib.messages.middleware.MessageMiddleware',
 57    'django.middleware.clickjacking.XFrameOptionsMiddleware',
 58]
 59
 60ROOT_URLCONF = 'blog.urls'
 61
 62TEMPLATES = [
 63    {
 64        'BACKEND': 'django.template.backends.django.DjangoTemplates',
 65        'DIRS': [BASE_DIR / 'blog/templates'],
 66        'APP_DIRS': True,
 67        'OPTIONS': {
 68            'context_processors': [
 69                'django.template.context_processors.debug',
 70                'django.template.context_processors.request',
 71                'django.contrib.auth.context_processors.auth',
 72                'django.contrib.messages.context_processors.messages',
 73
 74                'blog.context_processors.canonical',
 75                'blog.context_processors.base_url',
 76                'blog.context_processors.nav_items',
 77                'blog.context_processors.site_owner',
 78                'blog.context_processors.newsletter_page',
 79            ],
 80        },
 81    },
 82]
 83
 84WSGI_APPLICATION = 'blog.wsgi.application'
 85
 86
 87# Messages
 88# https://docs.djangoproject.com/en/3.0/ref/settings/#messages
 89
 90MESSAGE_TAGS = {
 91    messages.DEBUG: "alert-info",
 92    messages.INFO: "alert-info",
 93    messages.SUCCESS: "alert-success",
 94    messages.WARNING: "alert-warning",
 95    messages.ERROR: "alert-danger",
 96}
 97
 98
 99# Internationalization
100# https://docs.djangoproject.com/en/4.0/topics/i18n/
101
102LANGUAGE_CODE = 'en-us'
103TIME_ZONE = 'UTC'
104USE_I18N = True
105USE_TZ = True
106USE_THOUSAND_SEPARATOR = False  # NOTE: If setting to true this could cause issues with some srcset tags.
107
108
109# Static files (CSS, JavaScript, Images)
110# https://docs.djangoproject.com/en/4.0/howto/static-files/
111
112STATIC_URL = 'static/'
113STORAGES = {
114    "default": {
115        "BACKEND": "django.core.files.storage.FileSystemStorage",
116    },
117    "staticfiles": {
118        "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
119    },
120}
121STATICFILES_DIRS = (BASE_DIR / "blog/static",)
122STATIC_ROOT = BASE_DIR / "static"
123
124
125# Media files (Images, Videos)
126# https://docs.djangoproject.com/en/4.0/ref/settings/#media-root
127
128MEDIA_URL = 'media/'
129MEDIA_ROOT = BASE_DIR / "media"
130
131
132# Default primary key field type
133# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
134
135DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
136
137
138# Auth
139# https://docs.djangoproject.com/en/3.0/ref/settings/#auth
140
141AUTH_USER_MODEL = "accounts.User"
142
143
144# Wagtail
145# https://docs.wagtail.org/en/stable/reference/settings.html#settings
146
147WAGTAIL_SITE_NAME = "Blog"
148WAGTAIL_MODERATION_ENABLED = False
149WAGTAILADMIN_COMMENTS_ENABLED = False
150WAGTAIL_FRONTEND_LOGIN_URL = '/accounts/login/'
151TAG_SPACES_ALLOWED = False
152WAGTAIL_AUTO_UPDATE_PREVIEW = True
153WAGTAIL_USAGE_COUNT_ENABLED = True
154WAGTAILADMIN_RICH_TEXT_EDITORS = {
155    'default': {
156        'WIDGET': 'wagtail.admin.rich_text.DraftailRichTextArea',
157        'OPTIONS': {
158            'features': ['h2', 'h3', 'bold', 'italic', 'link', 'document-link','ol', 'ul', 'hr', 'blockquote', 'strikethrough', 'code']
159        }
160    }
161}
162WAGTAIL_WORKFLOW_ENABLED = False
163
164
165# django-taggit
166# https://django-taggit.readthedocs.io/en/latest/getting_started.html?highlight=TAGGIT_CASE_INSENSITIVE#getting-started
167
168TAGGIT_CASE_INSENSITIVE = True