PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Chapter 3: Setting up postgres #12

Closed yawtalkstechs closed 2 years ago

yawtalkstechs commented 2 years ago

When I try to migrate data after setting up postgresql and running this command:

zenx commented 2 years ago

@yawtalkstechs, can you verify that the database is running? Check the service running on port 5432 with the command: lsof -i :5432

yawtalkstechs commented 2 years ago

I enter the command but nothing was shown on the terminal. I add sudo to the command like this:

This is was shown at the terminal

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postgres 1080 postgres 3u IPv6 22144 0t0 TCP localhost:postgresql (LISTEN) postgres 1080 postgres 4u IPv4 22145 0t0 TCP localhost:postgresql (LISTEN)

yawtalkstechs commented 2 years ago

In the settings.py, I added HOST and PORT to databases. To make it look like this:

DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "blog", "USER": "blog", "PASSWORD": " ", "HOST": "localhost", "PORT": 5432 } }