R
Railway12mo 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
Percy12mo ago
Project ID: N/A
Lea
Lea12mo ago
Hi, lost again..not sure where was Project ID? dashboard? project ID : 032b06db-5b31-4dc7-96b1-5d543f0a9a4b
Solution
Brody
Brody12mo 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
Lea12mo 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
Brody12mo 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
Lea12mo ago
apologies
Lea
Lea12mo ago
No description
Lea
Lea12mo 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
Brody12mo 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
Lea12mo 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
Brody12mo ago
it's available in the standard library of python, you only need to import it the same way that sample code does
Lea
Lea12mo ago
thank you
Lea
Lea12mo 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
Lea12mo ago
this is my current setting in django:
No description
Brody
Brody12mo ago
it doesn't seem like you've done the two things I showed you?
Lea
Lea12mo ago
ee? possibly not I guess
Brody
Brody12mo ago
here's the message
Lea
Lea12mo 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
Brody12mo ago
awsome, glad i could help!
Want results from more Discord servers?
Add your server