diff --git a/inventory_project/settings.py b/inventory_project/settings.py index 0b30ede..29f048f 100644 --- a/inventory_project/settings.py +++ b/inventory_project/settings.py @@ -134,3 +134,8 @@ USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + + +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media') +SERVE_MEDIA_FILES = DEBUG \ No newline at end of file diff --git a/inventory_project/urls.py b/inventory_project/urls.py index 17b924d..9becace 100644 --- a/inventory_project/urls.py +++ b/inventory_project/urls.py @@ -15,9 +15,14 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf import settings +from django.conf.urls.static import static urlpatterns = [ path('', include('inventory.urls')), path('accounts/', include('django.contrib.auth.urls')), path('admin/', admin.site.urls), ] + +if settings.SERVE_MEDIA_FILES: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)