R
Railway13mo ago
Lea

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
No description
No description
No description
No description
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...
Jump to solution
19 Replies
Percy
Percy13mo ago
Project ID: N/A
Lea
LeaOP13mo ago
Hi, lost again..not sure where was Project ID? dashboard? project ID : 032b06db-5b31-4dc7-96b1-5d543f0a9a4b
Solution
Brody
Brody13mo ago
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
Lea
LeaOP13mo ago
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?
Brody
Brody13mo ago
sorry I don't see what you mean, all I see from your screenshot is that you sent one of them 3 times
Lea
LeaOP13mo ago
apologies
Lea
LeaOP13mo ago
No description
Lea
LeaOP13mo ago
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?
Brody
Brody13mo ago
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
Lea
LeaOP13mo ago
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?
Brody
Brody13mo ago
it's available in the standard library of python, you only need to import it the same way that sample code does
Lea
LeaOP13mo ago
thank you
Lea
LeaOP13mo ago
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 ?
No description
Lea
LeaOP13mo ago
this is my current setting in django:
No description
Brody
Brody13mo ago
it doesn't seem like you've done the two things I showed you?
Lea
LeaOP13mo ago
ee? possibly not I guess
Brody
Brody13mo ago
here's the message
Lea
LeaOP13mo ago
thanks, will try again, already found at least one mistake....thank you for help..hope lats one (: Just to say thank you..worked, closing
Brody
Brody13mo ago
awsome, glad i could help!
Want results from more Discord servers?
Add your server