postgresql error with django

1

error:

manage.py makemigrations
Traceback (most recent call last):
 File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\postgresql\base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\psycopg2\__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\djangopg\manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\core\management\__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\core\management\base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\core\management\commands\makemigrations.py", line 92, in handle
    loader.check_consistent_history(connection)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\migrations\loader.py", line 275, in check_consistent_history
    applied = recorder.applied_migrations()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\migrations\recorder.py", line 61, in applied_migrations
    if self.has_table():
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\migrations\recorder.py", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
    return self._cursor()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
    self.ensure_connection()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\django\db\backends\postgresql\base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\pcort\Documents\Programacion\programacionWeb\postgresql_django\venv\lib\site-packages\psycopg2\__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError

The only thing I have touched on the project is this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'pruebas',
        'USER': 'root',
        'PASSWORD': 'pruebas',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
    
asked by Pablo Cortes Rodriguez 11.01.2018 в 22:36
source

2 answers

1

The command is

python manage.py makemigratiions

and do not forget to have the virtual asset If the first time you run the migrations, before executing the makemigrations, execute the command:

python manage.py migrate 

To generate the default tables of Django

    
answered by 15.01.2018 в 22:51
0

Unfortunately you do not say what version of Python and Django you use, this information is important, nor do you mention if you have installed the PostgreSQL database management system

  

Django is compatible with PostgreSQL 9.3 and higher. Psiccopg2 2.5.4 or higher is required, although the most recent version is recommended.

'ENGINE': 'django.db.backends.postgresql_psycopg2',

django.db.backends.postgresql_psycopg2 according to the official documentation a>  it should be django.db.backends.postgresql

Documentation settings.py ENGINES (databases): link

    
answered by 16.01.2018 в 04:03