1

Al correr el comando python manage.py makemigrations me sale el siguiente error y no logro comprender a que se debe.

Agradezco su ayuda.

  • Versión de Python es 3.7.4

  • Versión de Django es 3.0.3

  • Versión de Psycopg2 es 2.8.4

Los parámetros que tengo en el archivo de configuración son los siguientes

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'articulosclientes',
    'USER': 'postgres',
    'PASSWORD': 'a123',
    'HOST':'127.0.0.1',
    'DATABASE_PORT':'5432'
}

Error:

C:\Users\Felipe Vargas\Documents\ProyectosDjango\TiendaOnline>python manage.py makemigrations
Traceback (most recent call last):
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
    self.connect()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\psycopg2\__init__.py", line 126, 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 "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\core\management\commands\makemigrations.py", line 101, in handle
    loader.check_consistent_history(connection)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\migrations\loader.py", line 283, in check_consistent_history
    applied = recorder.applied_migrations()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\migrations\recorder.py", line 76, in applied_migrations
    if self.has_table():
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 260, in cursor
    return self._cursor()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 236, in _cursor
    self.ensure_connection()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
    self.connect()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
    self.connect()
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\Felipe Vargas\Anaconda3\lib\site-packages\psycopg2\__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError 


1 respuesta 1

0

intenta hacer esto:

  1. Si anteriormente hiciste la migración de la base de datos, se debió de haber creado una carpeta dentro de tu aplicación que dice migrations, esa carpeta elimínala por completo (haz un backup si es que ya habías ingresado datos)

  2. Asegúrate de que tu configuración es correcta respecto al usuario y password.

  3. Cambia el puerto de entrada al 5433, si es que tienes la terminal del postgres, ingresa ahí y verás el puerto al que se está conectando por default. (ingresa ese, en mi caso es el 5433 no el 5432)

Espero te haya ayudado!

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.