Categories
Python Answers

How to fix Python Django cannot find static files?

Spread the love

Sometimes, we want to fix Python Django cannot find static files.

In this article, we’ll look at how to fix Python Django cannot find static files.

How to fix Python Django cannot find static files?

To fix Python Django cannot find static files, we can specify the template directory explicitly.

For instance, in settings.py, we write

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

to set STATICFILES_DIRS to a list of folders with the static file paths.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *