Reputation: 720
I have images downloaded in the following path but they refuse to load for me. Any idea what I may have configured incorrectly that is forcing this?
C:\Users\xxx\Python\Price Tracking\Django\mysite\polls\static\polls\images
settings:
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_plotly_dash.apps.DjangoPlotlyDashConfig',
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_URL = '/static/'
html:
{% load static %}
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="{% static 'polls/chicago.jpg' %}" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="{% static 'polls/nyc.jpg' %}" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="{% static 'polls/stl.jpg' %}" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Upvotes: 0
Views: 427
Reputation: 3717
First you write that images are in ... polls/static/polls/images/ but in the template tag you have /polls/xyz.jpg
For the rest you need to tell if you are in development with runserver and Debug=True (then files are taken from the app/static folders as you place them) or in deployment on e.g. a Apache server (then you need to serve them from Apache directly ... see serving static files on django docs
Upvotes: 1