经过长时间的搜索,关于postgre,关于manage.关于django_网站的py Killornot,没有什么能帮我解决这个错误:

Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying sites.0002_auto_20150929_1444...Traceback (most recent call last):
  **File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: must be owner of relation django_site**

上述异常是以下异常的直接原因:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/migrations/migration.py", line 108, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 139, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/schema.py", line 470, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/schema.py", line 642, in _alter_field
    self.execute(self._create_unique_sql(model, [new_field.column]))
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/var/www/webapps/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
    **return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: must be owner of relation django_site**

所以,在判断和重新判断之后,django网站在已安装应用列表中,site_id = 1;我的数据库工作正常,除了一些图像问题..然后我试着做了一些迁移,但这个错误一直在运行,我现在迫切地想找到问题所在.

有人有线索吗?

推荐答案

django用于连接数据库的数据库用户不是表的所有者.你需要在postgres shell上进行更改,或者pgadmin3可以提供帮助.

比如:

ALTER DATABASE your_db OWNER TO your_django_db_user
ALTER TABLE django_site OWNER TO your_django_db_user

Postgresql相关问答推荐

优化PostgreSQL查询以将用户插入数据库

如何在生成的列的表达式中使用TIMESTAMP WITH时区列?

使用pg_repack从PostgreSQL中的表中删除OID

PostgreSQL无效语法

让Docker Compose Container等待容器PostgreSQL并恢复

PostgreSQL中如何在同一行中存储多个与单个值相关的ID?

如何判断上次在 TimescaleDB 上运行连续聚合作业(job)的时间

无法从 docker-compose 上的其他服务解析 postgres 主机名

无法从在 wsl 2 上运行的服务之一连接到在 wsl 2 上的容器中运行的 postgres 数据库

如何防止 PDO 将问号解释为占位符?

PostgreSQL:是否可以将枚举转换为整数?

UPDATE implies move across partitions

如何将 DELETE 的返回值插入到 postgresql 中的 INSERT 中?

PostgreSQL 可以对数组元素有唯一性约束吗?

从 Postgres 数据库中删除所有函数

timezone date_trunc 函数

使用 postgres regexp_replace 将字符串列表替换为始终相同的字符串

在 PostgreSQL 中使用 Cursors进行分页

Android 的 JDBC 与 Web 服务

如何在 JPA 中使用 Postgres JSONB 数据类型?