Django 3: Static Files – images, JS, CSS, and Bootstrap 4
In this section, you will learn to add and manage static files in Django 3 Framework project. I will demonstrate how uploading and displaying images work, and at the same time I’ll show you how you can add JavaScript, CSS files and most importantly Bootstrap 4 with CDN and compiled source files locally as well.
You will learn to ..
- Upload and Display Images
- Add JavaScript files
- Add CSS files
- Add Bootstrap 4 with CDN
- Add Bootstrap 4 Compiled Source Files Locally
project/settings.py
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
project/urls.py
urlpatterns = [
path('', include('blog.urls')),
path('admin/', admin.site.urls),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)