styles not loading django app

Deployment id : 4fb6331a-8cc6-4463-b457-fd1785e3e658 I created a Django project. My site is properly running on local server. I have run the collectstatic command also. I have pushed all the changes to my github account also. I am using free version of Railway. It is deploying my site but not showing the css effects. It says this error : raif-production.up.railway.app/:1 Refused to apply style from 'https://raif-production.up.railway.app/static/css/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. I have set up all the static URLs and followed every single step on my local system. It is working fine there but not getting deployed properly. please help me out, I am stuck for more than 2 days. What should I do?
Solution:
How to configure whitenoise can be found in this repo https://www.github.com/railwayapp-templates/Django
Jump to solution
26 Replies
Percy
Percy16mo ago
Project ID: 4fb6331a-8cc6-4463-b457-fd1785e3e658
Brody
Brody16mo ago
please share your repo
pandeyganesha
pandeyganesha16mo ago
GitHub
GitHub - Ganesh910/raif
Contribute to Ganesh910/raif development by creating an account on GitHub.
Brody
Brody16mo ago
delete your procfile and replace it with this railway.json file
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn raif.wsgi"
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn raif.wsgi"
}
}
pandeyganesha
pandeyganesha16mo ago
New Deplyoment id: 2cdc4928-4200-4f41-b63b-40123dd7318a my problem still persists. Also there was i think some problem in json file. See in the attached image
Brody
Brody16mo ago
that's normal show me the build table at the top of the build logs
pandeyganesha
pandeyganesha16mo ago
wait
pandeyganesha
pandeyganesha16mo ago
pandeyganesha
pandeyganesha16mo ago
You can also see this.
MantisInABox
MantisInABox16mo ago
What is in your requirements.txt files?
pandeyganesha
pandeyganesha16mo ago
asgiref==3.7.2 Django==4.2.3 gunicorn==20.1.0 sqlparse==0.4.4 typing_extensions==4.7.1 I got this using pip freeze > requirements.txt
MantisInABox
MantisInABox16mo ago
In order to serve statis assets, you will need a package like whitenoise.
pandeyganesha
pandeyganesha16mo ago
Deploy logs
Solution
MantisInABox
MantisInABox16mo ago
How to configure whitenoise can be found in this repo https://www.github.com/railwayapp-templates/Django
pandeyganesha
pandeyganesha16mo ago
Okay, Let me follow these steps and tell you is my problem fixed or not. Thanks for your replies.
MantisInABox
MantisInABox16mo ago
You're very welcome.
pandeyganesha
pandeyganesha16mo ago
I am unable to find the steps. Do I just need to install whitenoise and add it to requirements.txt file only? or there are some extra steps of configuration?
Brody
Brody16mo ago
vin meant that you'd need to look at the code in that repo in order to understand how to configure it on your repo please carefully review the code in the repo vin linked
MantisInABox
MantisInABox16mo ago
There are 2 files you will want to edit 1. requirements.txt 2. settings.py - The settings file in the repo is a great starter for getting your project running on railway
pandeyganesha
pandeyganesha16mo ago
okay, let me see. Actually i am new to this, so bit confused. Trying my best to not to bother much. Thank you very very very very much. I was trying to solve the problem for 2-3 days. It is finally fixed. It is rendering the css also. thank you @Vin and thank you @Brody
MantisInABox
MantisInABox16mo ago
Awesome! You're good, no worries, that' what we do
Brody
Brody16mo ago
woohoo!
pandeyganesha
pandeyganesha16mo ago
I also don't use discord much. How do i mark this post as solved.......
Brody
Brody16mo ago
all done!
pandeyganesha
pandeyganesha16mo ago
ok thanks! Have a nice day, year, life ❣️
Brody
Brody16mo ago
thank you, you as well 🙂
Want results from more Discord servers?
Add your server