Reputation: 594
Django is not loading my static files. I'm trying to load an image from the static folder, but it doesn't work.
file.html
<body>
{% load static %}
<img src="{% static "products/logo.jpg" %}" alt="My image">
</body>
structure
app
|_______products
|_________templates
|_________file.html
|_________models.py
|_________ ...
|______static
|_________products
|_________logo.jpg
settings
...
INSTALLED_APPS = [
...
'django.contrib.staticfiles',
...
]
...
STATIC_URL = '/static/'
Upvotes: 0
Views: 52
Reputation: 691
<!DOCTYPE html>
<html>
<head>
{% load static %}
</head>
<body>
<img src="{% static "products/logo.jpg" %}" alt="My image">
</body>
</html>
settings:
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [STATIC_DIR, ]
Upvotes: 0
Reputation: 1269
You need to put this in your settings.py file:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Upvotes: 1