What are static files?
Make sure that you create a static folder in your root/base directory, like so:
# - Base/Root directory MyProject ---> MyProject (contains settings.py) ---> MyApp ---> static ---> templates ---> venv ---> db.sqlite3 ---> manage.py
Ensure that there that STATIC_URL is setup in settings.py:
# settings.py STATIC_URL = 'static/'
Configure Django to connect to our static folder.
In the code below, we are telling Django to look into our base directory and then to look for the static folder. After finding the static folder we are then saying that we want to bridge a connection.
# - settings.py import os # --------- Older way to configure -------- # STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] # --------- Newer way to configure -------- # STATICFILES_DIRS = [BASE_DIR / 'static']
As you can see there are two ways to configure Django to connect to our static folder. So, whether you are using an older or a newer version of Django, you are covered either way.