Postgres DB service added to Django App-but 2 sets of variebles appeared, need advice.
Evening, I would like to ask for advice. I just deployed my app and it failed due to postgre not config. Therefore I added service-Database-Postgres-when it finished deployment under Variables I had 2 sets of variables (see photo)? I was expecting only one set? I am not sure which of the sets of variables I should edit to connect to my existing datatabse as it is different name of DB and passowrd? Please. Thank you
Solution:Jump to solution
don't worry about the project id for your topic.
this is how you would want to setup your databases array in code https://github.com/railwayapp-starters/django/blob/main/mysite/settings.py#L81-L90
and then please read this docs section on how to setup the necessary database variables on your service
https://docs.railway.app/develop/variables#reference-variables...
19 Replies
Project ID:
N/A
Hi, lost again..not sure where was Project ID?
dashboard?
project ID : 032b06db-5b31-4dc7-96b1-5d543f0a9a4b
Solution
don't worry about the project id for your topic.
this is how you would want to setup your databases array in code https://github.com/railwayapp-starters/django/blob/main/mysite/settings.py#L81-L90
and then please read this docs section on how to setup the necessary database variables on your service
https://docs.railway.app/develop/variables#reference-variables
Thank you for quick help
But why do I have two sets in service? I got PG Databse and Postgres DB., which one to use?
sorry I don't see what you mean, all I see from your screenshot is that you sent one of them 3 times
apologies
I underlined whta is twice
Not sure if one set is for my existing DB and second for new one?
I tried few times to add and remove-perhaps that is reason?
ah I see what you mean now
different variable names are provided for backwards compatibility so that various apps that expect the variables to be named certain ways will still work.
the duplicate variables, even though named slightly different are in sync with each other.
if you where removing and adding variables on the database there is a good chance that it may have messed something up, I recommend you delete that database and deploy a new one, this time don't worry about the variables
once you have the current database deleted and you've added a new one, go back and follow these instructions please
sure, last question "envinron" package should be first installed in django and then used in array for DB variebles/con
under settings
or is envinron part of railway?
it's available in the standard library of python, you only need to import it the same way that sample code does
thank you
Hi, I am still bit lost, I managed to connect DB and tables from my app showed in Railway-DATA tab . They all and correct but not any data. on top, I still having failed deployment as my application it is not connected to DB and its actually right as name of my DB is not railway and my password and port is diffrent-in PGadmin I can get all details. However how should I connect existing DB to Railway? Should I alter Variebles in Railway-Postgres to whta is it in PG admin? Or do I need to add to djnago settings DB url con string ?
this is my current setting in django:
it doesn't seem like you've done the two things I showed you?
ee? possibly not I guess
here's the message
thanks, will try again, already found at least one mistake....thank you for help..hope lats one (:
Just to say thank you..worked, closing
awsome, glad i could help!