Find by Category

Django 3 Tutorial: Build a Blogging App

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 ..

  1. Upload and Display Images
  2. Add JavaScript files
  3. Add CSS files
  4. Add Bootstrap 4 with CDN
  5. 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)