PGPORT set correctly?
I keep getting this error when trying to deploy my project: "ValueError: invalid literal for int() with base 10: ' ' ". I believe that my PGPORT is not set up correctly in my shared variables, as I have inspected it and it seems to be an empty string. I'm a noob. Anyone has any ideas what I could try?
This is a django project, I'm trying to use postgresql (in Railway)
Solution:Jump to solution
variables don't need to be project level shared to be referenced by other services, once you delete that database and all of the shared variables you have created and have deployed a new one, please leave it as is.
then on your django service you would reference the
PGPORT
variable from the Postgres
service like so
```
PGPORT={{Postgres.PGPORT}}...9 Replies
Project ID:
b3aa5d3d-8985-46d1-8747-571b21b032d6
mind sharing how you set up your reference variable?
b3aa5d3d-8985-46d1-8747-571b21b032d6
Is set up as a global variable (which was auto created when I created a postgresql service: ${{Postgres.PGHOST}}
This is how I set it up in my settings.py file
PGPORT = config('PGPORT', default=5432, cast=int)
Strange
is it also an empty string in the postgres service variables?
Yep
Could you try creating a new Postgres service?
then delete the new Postgres service's volume
Disconnect the volume from the old service and then mount it to the new service
on this mount:
/var/lib/postgresql/data
you'll then have a new postgres service with hopefully fixed variables, which will have your old data as well
if you don't care about the old data then you can just delete both the old service and old mount
and deploy a new postgres serviceSure, let me try doing that.
all those variables are shared project variables indicated by the globe, they definitely shouldn't be.
after everything done to the database, it might be best to just scrap it and deploy another one, this time don't export the variables to global shared variables
Solution
variables don't need to be project level shared to be referenced by other services, once you delete that database and all of the shared variables you have created and have deployed a new one, please leave it as is.
then on your django service you would reference the
PGPORT
variable from the Postgres
service like so
then of course you just read the PGPORT
environment variable in code