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
Percy17mo ago
Project ID: 4fb6331a-8cc6-4463-b457-fd1785e3e658
Brody
Brody17mo ago
please share your repo
pandeyganesha
pandeyganeshaOP17mo ago
GitHub
GitHub - Ganesh910/raif
Contribute to Ganesh910/raif development by creating an account on GitHub.
Brody
Brody17mo 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
pandeyganeshaOP17mo 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
Brody17mo ago
that's normal show me the build table at the top of the build logs
pandeyganesha
pandeyganeshaOP17mo ago
wait
pandeyganesha
pandeyganeshaOP17mo ago
pandeyganesha
pandeyganeshaOP17mo ago
You can also see this.
MantisInABox
MantisInABox17mo ago
What is in your requirements.txt files?
pandeyganesha
pandeyganeshaOP17mo 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
MantisInABox17mo ago
In order to serve statis assets, you will need a package like whitenoise.
pandeyganesha
pandeyganeshaOP17mo ago
Deploy logs
Solution
MantisInABox
MantisInABox17mo ago
How to configure whitenoise can be found in this repo https://www.github.com/railwayapp-templates/Django
pandeyganesha
pandeyganeshaOP17mo ago
Okay, Let me follow these steps and tell you is my problem fixed or not. Thanks for your replies.
MantisInABox
MantisInABox17mo ago
You're very welcome.
pandeyganesha
pandeyganeshaOP17mo 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
Brody17mo 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
MantisInABox17mo 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
pandeyganeshaOP17mo 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
MantisInABox17mo ago
Awesome! You're good, no worries, that' what we do
Brody
Brody17mo ago
woohoo!
pandeyganesha
pandeyganeshaOP17mo ago
I also don't use discord much. How do i mark this post as solved.......
Brody
Brody17mo ago
all done!
pandeyganesha
pandeyganeshaOP17mo ago
ok thanks! Have a nice day, year, life ❣️
Brody
Brody17mo ago
thank you, you as well 🙂
Want results from more Discord servers?
Add your server