Can't load static file

I’ve looked everywhere and followed this How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django but I cannot get static files to load. I feel like I’m missing something really simple.

settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

STATIC_URL = 'static/'

Folder structure

├───littlelemon
│   ├───littlelemon
│   ├───restaurant
│   │   ├───static
│   │   │   ├───restaurant
│   │   │   │   └───logo.png
│   └───templates

index.html template

{% load static %}
<img src = "{% static 'restaurant/logo.png' %}"/>

index.html rendered code (what actually shows in the HTML)

<img src = "/static/restaurant/logo.png"/>

The image does not load on the index.html page and http://127.0.0.1:8000/static/restaurant/logo.png returns a 404

What am I missing?

Thank you.

I just figured it out. I did not install the ‘restaurant’ app in the INSTALLED_APPS in the settings.

Hope this helps someone else!

1 Like