Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused MIDDLEWARE_CLASSES, improve settings/dev.py comments #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions backend/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic', # < Per Whitenoise, to disable built in
# disable Django’s static file handling and allow WhiteNoise to take over
# http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'rest_framework',
'backend.api',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
# WhiteNoise middleware should be placed directly after the Django SecurityMiddleware
# http://whitenoise.evans.io/en/stable/django.html#enable-whitenoise
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand All @@ -58,7 +62,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# Add dist to
# use templates generated by vue (must match vue.config.js's outputDir)
'DIRS': ['dist'],
'APP_DIRS': True,
'OPTIONS': {
Expand Down Expand Up @@ -121,23 +125,12 @@
# When Vue Builds, path will be `/static/css/...` so we will have Django Serve
# In Production, it's recommended use an alternative approach such as:
# http://whitenoise.evans.io/en/stable/django.html?highlight=django

MIDDLEWARE_CLASSES = (
'whitenoise.middleware.WhiteNoiseMiddleware',
)

STATIC_URL = '/static/'
# Place static in the same location as webpack build files
# STATIC_ROOT must match vue.config.js's outputDir + assetsDir
# http://whitenoise.evans.io/en/stable/django.html#make-sure-staticfiles-is-configured-correctly
STATIC_ROOT = os.path.join(BASE_DIR, 'dist', 'static')
STATICFILES_DIRS = []


##########
# STATIC #
##########

# http://whitenoise.evans.io/en/stable/django.html?highlight=django#add-compression-and-caching-support
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

# Insert Whitenoise Middleware at top but below Security Middleware
# MIDDLEWARE.insert(1, 'whitenoise.middleware.WhiteNoiseMiddleware',)
# http://whitenoise.evans.io/en/stable/django.html#make-sure-staticfiles-is-configured-correctly