Hello, as title says, i have a problem with my production website, i made all proccess through the static files thing and it works fine i actually just realized that sometimes when you enter the website there are a few pictures missing, then you instantly refresh and it goes back to normal it happens randomly and i trul y don’t know what’s causing it, that’s the reason of why im creating this thread, hopefully you guys will be able to give me a hand. Thanks in advance
PS: Hosting at Linode.
There’s not really a lot of specifics supplied here so it’s difficult to offer direct advice.
So looking at things in general:
- Check your browser’s developer tools / network tab to see if the requests are being made for those images, and what the response codes are.
- Check your webserver logs for errors on those requests
- Check your application logs
- Check the page that is rendered to verify that the URLs are being constructed correctly.
Sorry for the poor information about the website, sometimes it loads properly … sometimes it doesn’t, here is what i found when it failed…
Also, here is the URL of the website https://gnetwork.us
Thanks for the quick reply
That’s helpful - you’re getting a 500 error which indicates a problem on the server. You’ll need to check out your server logs. They should have more details about what failed and how.
It might also be worth turning DEBUG on for a brief period to get more detailed information.
How are you serving your static files and media (user uploaded) files? Is that being done through nginx/apache, etc or are you serving it through the Django app and whitenoise?
Im not gonan lie, im pretty pretty new to production environments haha … i just served them following this tutorial Python Programming Tutorials
DEBUG = False and add your hostname.
Then scroll to the end of the file, you should find
STATIC_URL = '/static/' , add right below it:
STATIC_ROOT = ‘/var/www/mysite/static/’ MEDIA_URL = ‘/media/’ MEDIA_ROOT = ‘/var/www/mysite/media/’
Exit that, and now we need to run:
python3 manage.py collectstatic
This will copy all of your static files to one spot for production.
service apache2 reload
So that’s the way im serving files, im using apache and i don’t have whitenoise installed, as i said im just serving them the way that tutorial teached haha, thanks for the quick response guys, pretty excited to see and learn how to solve this and of course learning better practises.
As Ken said, you’ll need to check your server logs. In this case it’s apache’s logs. Here’s a Q&A post that should help you find them.
Im stoopid, i realized i wass using the. testing file, i had a sqlite3 daabase connected to it, checking logs i realized it close the db connection and that was causing problem with the files … Now i will swap to Postgresql and i guess it will be fixed, otherwise i’ll be bck to you but for now thanks for the replies so far guys