What to do when Django's static files are not working
Oct. 3, 2020, 8:22 a.m.
Sometimes when you start a new Django project , you may find that your static files are not working . If you are getting this problem then it means you have to set up this line STATICFILES_DIRS = [ ]
in your settings.py
file correctly. it should be pointing to the path where your static files which are independent of any app are found
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
static files which are inside an app are automatically found by Django , for example lets say your app name is blog , your static files will be located in /blog/static/blog/
, these will be found automatically by Django.
Resources
Keep Learning
- Django Class Based Views vs Function Based Views
- What Is Select_related in Django
- Understand clean() and clean_<fieldname>() in Django