Last active
February 21, 2017 00:04
-
-
Save mrchrisadams/8119ce3edc14d68fe1df35b03bd523e3 to your computer and use it in GitHub Desktop.
Messing around and using AWS Lambda wrong. These are the settings I got working in the end. I'm tired, and almost definitely using Whitenoise wrong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIDDLEWARE = [ | |
'django.middleware.security.SecurityMiddleware', | |
# new | |
'whitenoise.middleware.WhiteNoiseMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
] | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.10/howto/static-files/ | |
STATIC_URL = 'https://blablabla.execute-api.eu-central-1.amazonaws.com/dev/static' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# at the top: | |
import os | |
from django.conf import settings | |
from django.conf.urls.static import static | |
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | |
### your UrlConf as usual | |
HACKISH_DOC_ROOT = os.path.join(settings.BASE_DIR, 'staticfiles') | |
# Serve static and media files from development server | |
urlpatterns += staticfiles_urlpatterns() | |
urlpatterns += static('static', document_root=HACKISH_STATIC_FILES_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
WSGI config for my_site project. | |
It exposes the WSGI callable as a module-level variable named ``application``. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ | |
""" | |
import os | |
from django.core.wsgi import get_wsgi_application | |
from whitenoise.django import DjangoWhiteNoise | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_site.settings") | |
application = get_wsgi_application() | |
# Wrap the application, so Whitenoise serves static first | |
application = DjangoWhiteNoise(application) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment