I set up an Azure storage account to serve my static files and media, but now all my links from within my templates which are referencing the static path are broken.
From what I can tell it’s missing a / after the {% static '' %} which means the path is now https://#################.blob.core.windows.net/static/mediaassets/plugins/owl-carousel/owl.carousel.css but should be
Within all my templates I have the following syntax <link href="{% static '' %}assets/plugins/gallery/gallery.css" rel="stylesheet">
Other than going through every single template and adding the / before the assets does anyone know how this path is being formed so that i can just make a single change?
This was what was given as part of a theme that i brought, so its in every single html file. Does this mean i have to change every file
Only now has it become a problem - it works when serving files locally. If i have to change every file then that’s what I will do. Just hoping that’s not the case
What was in every theme? If it was "{% static '' %}some/dir/file.ext" then you got ripped off and should demand your money back.
If it was just "{% static '' %}", then you should have inserted the some/dir/file.ext in the quotes within the tag.
But yes, you should do that with every instance of the static tag.
How Django manages static files in development is significantly different than how they need to be managed in production. What works in one does not directly correlate to how it will work in the other.
I’m still running this locally, but serving static and media from azure storage. Which is now broken. BUT if i use white noise for production would the azure storage account still work do you know?
No clue on that, but the other thing I noticed is that your STATIC_ROOT setting should end with a “/”. (While it is not explicitly stated at Settings | Django documentation | Django to be the case, it’s implied there.) However, I don’t think that’s necessarily the problem, because I’m not consistent across my projects.
Sorry, I don’t use either azure or whitenoise, so I’m not going to be any help there.
The way I understand it is that the {% static %} template directive is a wrapper around its argument, and simply prepends it with the STATIC_URL settings value. I may be very wrong about that though, so do no take my word for it – but it does have helped me understand how and why it worked the way it works.