【问题标题】:CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA创建表 \"django_migrations\" (\"id\" bigint NOT NULL PRIMA
【发布时间】:2022-11-03 00:03:24
【问题描述】:
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/p.gauthamprasad/Downloads/pb/pbapp/manage.py", line 22, in <module>
    main()
  File "/Users/p.gauthamprasad/Downloads/pb/pbapp/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 107, in migrate
    self.recorder.ensure_schema()
  File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 72, in ensure_schema
    raise MigrationSchemaMissing(
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (permission denied for schema public
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
                     ^
)

我在创建数据库后尝试了这个“命令 python3 manage.py migrate” 并在 settings.py 中链接 这样...:-

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '<name>',
        'USER': '<username>',
        'PASSWORD': 'admin',
        'HOST': 'localhost',
        'PORT': '5432',

    }
}

我已经尝试在 psql 中授予“命令”没有用

【问题讨论】:

    标签: psql django-migrations


    【解决方案1】:

    如果您在 Windows 上,这可能会对您有所帮助。

    打开 PG-ADMIN 登录到本地服务器。

    右键单击您的用户。 单击属性并选择权限选项卡。 为您的用户选择超级用户选项,如下所示。

    并再次运行您的迁移和迁移命令,它应该可以工作。

    如果您在 linux 上,则必须检查权限。 您可以按照以下链接

    https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-django-application-on-ubuntu-20-04

    【讨论】:

      猜你喜欢
      • 2022-10-03
      • 2016-08-10
      • 2021-04-04
      • 2018-09-12
      • 2018-09-12
      • 1970-01-01
      • 2018-07-13
      • 2015-07-23
      • 2018-11-21
      相关资源
      最近更新 更多