Trouble ussing Buddy to test a project using Django REST FRAMEWORK POSTGRE AS DB

95 Views Asked by At

Hello I'm currently trying to implement Buddy with my little StartUp that is using DJANGO REST FRAMEWORK as a base. I found a very good example on the site. Unfortunately in the exmaple the used a MySql DB and I'm using Postgre as DB. My settings.py is:

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'DBname',
    'USER': 'DBuser',
    'PASSWORD': 'DBpassword',
    'HOST': '',
    'PORT': '5432',
    }
}
}

My Buddy execute look somethig like this:

pip install -r requirements.txt
cd Project
python manage.py test

I also created postgre service in Buddy like version: latest, Hostname: postgres, Port:5432, Login:DBuser, Password:DBpassword, Name of a database to be created on container startup: DBname When I run the build Test of my project an error message apears like this:

connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Action failed: see logs above for details

I really don't now how to fix this, it appears that Buddy creates the database correctly but for some reason django does not reconise that it exists.

Pd: The proyect works fine on my laptop and my friends. I'ts only when I tried to run it on buddy where it gives me problems

0

There are 0 best solutions below