absolute newbie: how can I use python 3.12 and django 5.0 when I deploy my app?
project ID: 6ec4e69f-153c-42b1-8399-d4fbd6db04fb
I have a django app that runs happily on my computer but when I try and deploy to railway I get errors saying that it is using python38, despite having a runtime.txt file with "Python 3.12.1" in it (I have no idea if that is the right thing to do, but it was what one of the few recent-ish youtube tutorials I could find suggested). Would someone be able to tell me/link to a way for me to use the latest version of python? Thanks!
55 Replies
Project ID:
6ec4e69f-153c-42b1-8399-d4fbd6db04fb
I have no idea if that is the right thing to doyes it is, however nixpacks does not currently support python 3.12, the latest nixpacks supports is 3.11
3.11 would probably work - would you be able to tell me how to take my django project and wrap it up with a pretty bow for railway? 😄
put
3.11
into your runtime.txt and redeployjust 3.11 or "Python 3.11"?
either should work
found this in the logs after a build fail:
full build logs please https://bookmarklets.up.railway.app/log-downloader/
there ye go!
try adding this as a nixpacks.toml file to your project
in the same dir as runtime.txt?
yep
another build fail, pycairo
ive updated this, try again please
still cant build wheels
alright time to abandon nixpacks, delete the nixpacks.toml file and then create a
Dockerfile
with this in it
here's the repo
https://github.com/meaniebeanie22/tkd-manager
GitHub
GitHub - meaniebeanie22/tkd-manager
Contribute to meaniebeanie22/tkd-manager development by creating an account on GitHub.
delete your Procfile while youre at it
deploying...
ah good then we have made it farther
sad gunicorn in deploy logs
updated, forgot a dash lol
back at it again
when railway does environment variables are they all strings?
environment variables on any platform or even any OS will always be strings
beans
why is that beans?
that doesnt stop you from setting numbers, the numbers will just be stored as a string
i had debug set to DEBUG = os.environ.get("DEBUG", True)
so a string of "False" still == True
yeah you'd need to parse a string to a bool
ill just check if the string == "False" and if so then set DEBUG = False
that also works
oh and this
ALLOWED_HOSTS = ["*"]
thats more so just a generic error, not all that related to deploying on railway, im sure there are a bunch of great tutorials for setting up csrf, that page even tells you a lot of what you need to know
was working a minute ago with py -3 manage.py runserver
thats a development server, absolutely not something you want to be running on railway
yeah I know
not really sure how to fix all this though :D
i am not a python developer myself, so this is about all the advice i can offer you
ahh okay
will try adding https:// *.railway.app to CSRF_TRUSTED_ORIGINS
after that i have to figure out getting the database to work
because atm it just sits in my repo with the other bits in a default config
yeah please dont use sqlite going forward
no volume or other db in the railway thing
postgres would be your best bet
it was the default and it just worked so I haven't needed to change until now where i wanted to see if i could get something to deploy
thats fair
okay some of the css is a tad dodgy but thats something I can probably fix
if i want to add requirements i should just add them to requirements.txt right and everything should work?
yep that works all the same with the dockerfile I've provided
cheers mate!
Cheers!
Is there any way that I can take my freshly migrated postgres database and upload its contents to railway?
you have a local postgres database?
yes
made one and migrated my sqlite3 one across
then you would want to look into pg_dump and pg_restore
thanks!
Database migrated (or at least i think so - all the tables i can understand)
now the issue is i am apparently getting too many redirects
fixed!
add
to settings.py
I may not be a python developer but I'm still able to understand right and wrong, and that is indeed the right way to solve that issue