diff --git a/polisplexity/settings.py b/polisplexity/settings.py index c4cda2b..4aaa41e 100644 --- a/polisplexity/settings.py +++ b/polisplexity/settings.py @@ -159,6 +159,7 @@ STATICFILES_DIRS = [ MEDIA_URL = "/media/" MEDIA_ROOT = BASE_DIR / "media" +SERVE_MEDIA = os.getenv("SERVE_MEDIA", "").lower() in ("1", "true", "yes") # Default primary key field type diff --git a/polisplexity/urls.py b/polisplexity/urls.py index 29a642e..8706c42 100644 --- a/polisplexity/urls.py +++ b/polisplexity/urls.py @@ -65,4 +65,6 @@ urlpatterns = [ if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + +if settings.DEBUG or settings.SERVE_MEDIA: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)