Add settings.SERVE_FILES and serve static files only for local development

pull/18/head
JensDiemer 2020-11-11 18:35:42 +01:00
rodzic 1bd3104397
commit b051ec72da
3 zmienionych plików z 17 dodań i 3 usunięć

Wyświetl plik

@ -7,11 +7,18 @@ from pathlib import Path as __Path
from django.utils.translation import ugettext_lazy as _
# Build paths inside the project:
BASE_PATH = __Path(__file__).resolve().parent.parent.parent
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
# Serve static/media files by Django?
# In production Caddy should serve this!
SERVE_FILES = False
# SECURITY WARNING: keep the secret key used in production secret!
__SECRET_FILE = __Path(BASE_PATH, 'secret.txt').resolve()
if not __SECRET_FILE.is_file():

Wyświetl plik

@ -15,6 +15,11 @@ from inventory_project.settings.base import * # noqa
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# Serve static/media files for local development:
SERVE_FILES = True
# Disable caches:
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}

Wyświetl plik

@ -15,10 +15,12 @@ urlpatterns = [ # Don't use i18n_patterns() here
path('ckeditor/', include('ckeditor_uploader.urls')), # TODO: check permissions?
]
if settings.DEBUG:
if settings.SERVE_FILES:
urlpatterns += static.static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
import debug_toolbar
if settings.DEBUG:
import debug_toolbar
urlpatterns = [url(r'^__debug__/', include(debug_toolbar.urls))] + urlpatterns