Skip to content

Commit 5a4733e

Browse files
committed
Add static file handlers
1 parent f4409ce commit 5a4733e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

web_project/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,9 @@
119119
# https://docs.djangoproject.com/en/2.1/howto/static-files/
120120

121121
STATIC_URL = '/static/'
122+
123+
# The location where the collectstatic command collects static files from apps.
124+
# A dedicated static file server is typically used in production to serve files
125+
# from this location, rather than relying on the app server to serve those files
126+
# from various locations in the app. Doing so results in better overall performance.
127+
STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')

web_project/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
from django.contrib import admin
1818
from django.urls import path
1919
from django.urls import include
20+
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
2021

2122
urlpatterns = [
2223
path('', include('hello.urls')),
2324
path('admin/', admin.site.urls), # Activates the admin interface
2425
]
26+
27+
urlpatterns += staticfiles_urlpatterns()

0 commit comments

Comments
 (0)