So I have my static url set as such under settings:
settings.py
STATIC_URL = '/static/'
if DEBUG or not DEBUG:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'tabular', 'templates'),
os.path.join(BASE_DIR, 'common'),
)
Then here is my folder path with the static files
I have a webpage with logo.png and step1.png-step4.png. For some odd reason when I'm running in deployment, it correct fetches logo.png, but not step1.png-step4.png.
Here is the html code.
<div id="wrapper">
<div id="container">
<img style="padding: 1em;" src="{% static 'images/logo.png' %}" />
<form
class="form-horizontal"
enctype="multipart/form-data"
id="data_upload"
method="POST"
>
{% csrf_token %}
<div class="input-group mb-3">
<div class="custom-file">
<input
accept=".csv"
class="custom-file-input"
id="file_input"
name="file"
type="file"
/>
<label
aria-describedby="inputGroupFileAddon02"
class="custom-file-label"
for="inputGroupFile02"
id="submit_label"
>Upload CSV</label
>
</div>
<div class="input-group-append">
<button
class="input-group-text btn"
id="upload_button"
type="submit"
disabled
>
Upload
</button>
</div>
</div>
<div id="progress_div" class="progress" style="visibility: hidden;">
<div
id="progress_bar"
class="progress-bar"
role="progressbar"
style="width: 0%;"
aria-valuenow="25"
aria-valuemin="0"
aria-valuemax="100"
></div>
</div>
<br />
<div
id="spinner"
class="d-flex justify-content-center"
style="visibility: hidden;"
>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</form>
</div>
</div>
<div
class="modal fade"
id="my_modal"
tabindex="-1"
role="dialog"
data-target="#my_modal"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal_title">Modal title</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div id="modal_body" class="modal-body"></div>
</div>
</div>
</div>
<div
class="modal fade"
id="how_to_modal"
tabindex="-1"
role="dialog"
data-target="#how_to_modal"
aria-hidden="true"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal_title">How To</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div
id="carouselExampleCaptions"
class="carousel slide"
data-ride="carousel"
>
<ol class="carousel-indicators" style="color: black;">
<li
data-target="#carouselExampleCaptions"
data-slide-to="0"
class="active"
></li>
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img
src="{% static 'imgs/step1.png' %}"
class="d-block w-100"
alt="..."
/>
</div>
<div class="carousel-item">
<img
src="{% static 'imgs/step2.png' %}"
class="d-block w-100"
alt="..."
/>
</div>
<div class="carousel-item">
<img
src="{% static 'imgs/step3.png' %}"
class="d-block w-100"
alt="..."
/>
</div>
<div class="carousel-item">
<img
src="{% static 'imgs/step4.png' %}"
class="d-block w-100"
alt="..."
/>
</div>
</div>
<a
class="carousel-control-prev"
href="#carouselExampleCaptions"
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="#carouselExampleCaptions"
role="button"
data-slide="next"
>
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
Problem
Here's what console prints in Google Chrome dev
GET https://blackboxml.cs.ubc.ca/static/imgs/step1.png 404 (Not Found)
GET https://blackboxml.cs.ubc.ca/static/imgs/step2.png 404 (Not Found)
GET https://blackboxml.cs.ubc.ca/static/imgs/step3.png 404 (Not Found)
GET https://blackboxml.cs.ubc.ca/static/imgs/step4.png 404 (Not Found)
When I run this on my personal windows in debug mode, the images display properly. Also another weird thing is the css for the html is in the same folder, but that gets loaded properly but not the pngs.
ls -l
-rw-r----- 1 virtuecc fwood 52176 Jun 4 16:27 step1.png
-rw-r----- 1 virtuecc fwood 32364 Jun 4 16:27 step2.png
-rw-r----- 1 virtuecc fwood 38267 Jun 4 16:27 step3.png
-rw-r----- 1 virtuecc fwood 49833 Jun 4 16:27 step4.png
Other file
-rw-r----- 1 virtuecc fwood 9727 May 28 15:30 logo.png
What I've tried
- I put all the pngs in the same folder 'common/images' and still only logo.png got fetched successfully.
- I was also told running the command "python manage.py collectstatic" should fix this. I got this tip off "https://www.youtube.com/watch?v=m0zEz_qdPLY"
Specifictations
- Web server is Ubuntu
- Django 3.0.7
- Python 3.6.9
Can anyone tell me why this is happening? The ultimate goal is just to serve the statics to the website during deployment if there's a better way to do this I'm open to suggestions as well.

