mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-13 09:32:26 +03:00
make it possible to serve up static assets using dj-static instead of S3
This commit is contained in:
parent
337269648d
commit
a6eefe40b9
|
@ -1 +1 @@
|
||||||
web: python {{cookiecutter.repo_name}}/manage.py run_gunicorn --settings=config.settings -b "0.0.0.0:$PORT" -w 3
|
web: gunicorn {{cookiecutter.repo_name}}/config/wsgi.py
|
|
@ -6,3 +6,4 @@ gunicorn==0.17.4
|
||||||
django-storages==1.1.4
|
django-storages==1.1.4
|
||||||
gevent==0.13.8
|
gevent==0.13.8
|
||||||
boto==2.9.5
|
boto==2.9.5
|
||||||
|
dj-static==0.0.5
|
|
@ -326,6 +326,7 @@ class Production(Common):
|
||||||
|
|
||||||
INSTALLED_APPS += ("gunicorn", )
|
INSTALLED_APPS += ("gunicorn", )
|
||||||
|
|
||||||
|
try: # serve static assets using S3
|
||||||
########## STORAGE CONFIGURATION
|
########## STORAGE CONFIGURATION
|
||||||
# See: http://django-storages.readthedocs.org/en/latest/index.html
|
# See: http://django-storages.readthedocs.org/en/latest/index.html
|
||||||
INSTALLED_APPS += (
|
INSTALLED_APPS += (
|
||||||
|
@ -352,6 +353,15 @@ class Production(Common):
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||||
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||||
########## END STORAGE CONFIGURATION
|
########## END STORAGE CONFIGURATION
|
||||||
|
except: # serve static assets using wsgi
|
||||||
|
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
STATIC_ROOT = 'staticfiles'
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
STATICFILES_DIRS = (
|
||||||
|
join(PROJECT_PATH, 'static'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
########## EMAIL
|
########## EMAIL
|
||||||
DEFAULT_FROM_EMAIL = values.Value(
|
DEFAULT_FROM_EMAIL = values.Value(
|
||||||
|
|
|
@ -26,7 +26,9 @@ os.environ.setdefault("DJANGO_CONFIGURATION", "Local")
|
||||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||||
# setting points here.
|
# setting points here.
|
||||||
from configurations.wsgi import get_wsgi_application
|
from configurations.wsgi import get_wsgi_application
|
||||||
application = get_wsgi_application()
|
from dj_static import Cling
|
||||||
|
|
||||||
|
application = Cling(get_wsgi_application())
|
||||||
|
|
||||||
# Apply WSGI middleware here.
|
# Apply WSGI middleware here.
|
||||||
# from helloworld.wsgi import HelloWorldApplication
|
# from helloworld.wsgi import HelloWorldApplication
|
||||||
|
|
Loading…
Reference in New Issue
Block a user