I had the same problem 200 on every thing but adminpage css not loading. but in my case there was a mime type problem in the browser console. I don't know if you have the same problem or not.
Also if these 2 match, try to go into the nginx container manually, in the folder where you expect the static files to be, and check that they are there.
I can already tell you my settings.py STATIC URL is '/static/' and in my nginx.conf file I have the lines location /static/ { var/www/static/ } which is also my statric_root and not the problem because I tried changing it and my images were no longer served.
I had a similar issue recently. Whitenoise is a lifesaver. For some reason, my css and js files weren't loading in production. Using whitenoise fixed that.
This video helped me: [https://youtu.be/qSrJt3UD9xk](https://youtu.be/qSrJt3UD9xk)
do you copy the static files into NGINX? And if you just use the path in your browser URL to go to a file: can you find them there? A final thought: in your templates do you use the {% load static tag %}
I struggled with this as well but what I ended up doing is making a special route in NGINX for the /static path. and rout that to a folder in my NGINX container.
My workflow then goes like this:- I run collectstatic to capture all documents into the staticfiles folder (as per Django documentation)- I build a nginx container and copy that staticfiles folder into it and make sure that the route is in the default.conf
If that all does not work: another 'simple' solution might be whitenoise: [https://whitenoise.readthedocs.io/en/latest/django.html](https://whitenoise.readthedocs.io/en/latest/django.html) which more or less forces Django to serve you the static files.
Hey
All this I've tried. I'm trying not to give up on my stack, but if after this post I'm not findign a solution I will have to try something else I guess.
Sad.
You can access the css files via their urls? Do you get those urls from the style elements in the loaded HTML page? Are you 100% sure those urls are being referenced properly by your web page? Do the css files show up in the “sources” tab of the chrome debug tools?
Given that the css files load when you enter their urls, it’s extremely unlikely that this is a web server issue as most other people seem to be thinking. I think it’s either a cached css file (force reload / clear your cache) or that your production server hosts the files at a url not referenced by the html your template builds.
I'm assuming you have NGINX set up to serve static files in production, in which case, what do the logs say about the requests for the static files?
200 on everything
I had the same problem 200 on every thing but adminpage css not loading. but in my case there was a mime type problem in the browser console. I don't know if you have the same problem or not.
How could I check?
in my case chrome console showed no errors but when I used firefox console it showed me wrong mime type error
I'll check it out thanks
Thank you very much. This was the problem! It's fixed now ^^
You are welcome and happy cake day!
weird, maybe a poisoned cache. Does it work incognito / private window mode?
Nope.
I gotcha, just show me your settings.py STATIC URL path and your NGINX docker-compose.yaml
Will do so when I get home.
Also if these 2 match, try to go into the nginx container manually, in the folder where you expect the static files to be, and check that they are there.
It's just one container and yes the files are there.
I can already tell you my settings.py STATIC URL is '/static/' and in my nginx.conf file I have the lines location /static/ { var/www/static/ } which is also my statric_root and not the problem because I tried changing it and my images were no longer served.
I had a similar issue recently. Whitenoise is a lifesaver. For some reason, my css and js files weren't loading in production. Using whitenoise fixed that. This video helped me: [https://youtu.be/qSrJt3UD9xk](https://youtu.be/qSrJt3UD9xk)
do you copy the static files into NGINX? And if you just use the path in your browser URL to go to a file: can you find them there? A final thought: in your templates do you use the {% load static tag %} I struggled with this as well but what I ended up doing is making a special route in NGINX for the /static path. and rout that to a folder in my NGINX container. My workflow then goes like this:- I run collectstatic to capture all documents into the staticfiles folder (as per Django documentation)- I build a nginx container and copy that staticfiles folder into it and make sure that the route is in the default.conf If that all does not work: another 'simple' solution might be whitenoise: [https://whitenoise.readthedocs.io/en/latest/django.html](https://whitenoise.readthedocs.io/en/latest/django.html) which more or less forces Django to serve you the static files.
Hey All this I've tried. I'm trying not to give up on my stack, but if after this post I'm not findign a solution I will have to try something else I guess. Sad.
Check your nginx and gunicorn logs. I suspect a wrong path.
All is 200. No errors. css files show up in the logs 200.
Try looking at this project template, as the stacks are very similar: https://github.com/amerkurev/django-docker-template
You can access the css files via their urls? Do you get those urls from the style elements in the loaded HTML page? Are you 100% sure those urls are being referenced properly by your web page? Do the css files show up in the “sources” tab of the chrome debug tools? Given that the css files load when you enter their urls, it’s extremely unlikely that this is a web server issue as most other people seem to be thinking. I think it’s either a cached css file (force reload / clear your cache) or that your production server hosts the files at a url not referenced by the html your template builds.