hey guys so i’m follwing this guide
https://dev.to/mr_destructive/django-postgresql-deployment-on-railway-app-d54
on how to deploy my django project on railway
i have everything set locally, it working but once i deploy, the app crashes returning this err
File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/backends/dummy/base.py", line 20, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
below is my database setting
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': os.environ.get('PGHOST'),
'NAME': os.environ.get('PGDATABASE'),
'USERNAME': os.environ.get('PGUSER'),
'PASSWORD': os.environ.get('PGPASSWORD'),
'PORT':os.environ.get('PGPORT')
}
}
by the way, this is working on my localhost, i only get this err when i deploy to railway
can someone pls help out
2
Answers
Use this setting for postgresql:
}
REF: https://docs.djangoproject.com/en/4.1/ref/settings/#databases
You need to add the relevant environment variable names to the railway app variable settings. To add variables click
+ New Variable
and it will prompt you to enter the variable name and its value in it. Copy the Database Connection URL from the PostgreSQL service settings and paste in the app variablesDATABASE_URL
‘s valueIf you think the method isn’t working for you, you can also try the second approach.
You can add the database URL as a single string as well, this is also an alternative rather than specifying all the separate fields.