python manage.py迁移错误

时间:2016-09-01 11:11:06

标签: django migrate manage.py

我正在学习Django,并尝试使用该命令迁移manage.py python manage.py migrate。但是发生的事情是

(venv) Kaustubhs-MacBook-Pro-2:crmeasy kaustubhmundra$ python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 63, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 17, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 48, in __init__
    self.build_graph()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 179, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.get_table_list(self.connection.cursor()):
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 165, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 138, in _cursor
    self.ensure_connection()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 133, in ensure_connection
    self.connect()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 133, in ensure_connection
    self.connect()
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 122, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 134, in get_new_connection
    return Database.connect(**conn_params)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL:  password authentication failed for user "postgres"

2 个答案:

答案 0 :(得分:2)

您应该在 settings.py 中添加 postgres 用户的正确密码,因为它显示为FATAL: password authentication failed for user "postgres"

答案 1 :(得分:0)

设置postgres

的密码
sudo -u postgres psql

在psql终端

\password postgres

设置密码并将其添加到settings.py文件