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