Are you trying to use static files in your Django project deployed on Railway platform?
I make this guide not only for myself (yeah I have a not-so-good memory and keeping here my notes could be a good choice where I can check anytime I stuck in some problem), but for everyone else as well that are not able to deploy their Django app, so here I wrote a list of good actions to follow in order deploy the app.
This guide is valid either you have DEBUG=False or DEBUG=True.
Sooo now pay attention to these steps in order not to run into an error:
Keep watching on this template
startCommand
command at https://github.com/railwayapp-templates/django/blob/main/railway.json
that has the same content that has to be used in our Procfile
and https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py
which may have new settings to add to our settings.py.Keep track of the latest
whitenoise
docs at: https://whitenoise.readthedocs.io/en/latest/django.htmlKeep watching also of the official docs for further or new explanations at:
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/DeploymentMake sure there is command
collectstatic
inside the Procfile or deploy command section of Railway settings app.Make sure that on Railway settings of the app there is no Deploy -> Start Command set value since there is already inside the Procfile or viceversa.
Make sure that on Railway settings of the app there is the correct path
/
or subpath/...
at General -> Root Directory set.Make sure that requirements.txt, Procfile and runtime.txt are in the same folder of the Django manage.py file.
Make sure that inside Procfile there is the right
myapp.wsgi
command text.
Ok that's all folks, have a nice coding!
Top comments (0)