gpt4 book ai didi

Django loaddata 返回关系被拒绝的权限

转载 作者:行者123 更新时间:2023-11-29 11:57:16 24 4
gpt4 key购买 nike

我正在尝试使用 loaddata 从 django 项目上的转储数据生成的 json 文件中加载一些数据,并将其加载到具有新数据库的新文件中。与数据库的连接似乎可以正常工作,但几乎马上我就收到了对关系 django_content_type 的拒绝许可。我没有得到我们正在谈论的许可。数据库是单独服务器上的 postgres,我通过笔记本电脑上具有虚拟环境的流浪虚拟机连接到它,并且 settings.py 具有连接到数据库的设置。这是回溯:

Problem installing fixture 'djgprd1_dumpdata.json': Traceback (most recent call last):
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 196, in handle
obj.save(using=using)
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/base.py", line 524, in save_base
manager.using(using).filter(pk=pk_val).exists())):
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 565, in exists
return self.query.has_results(using=self.db)
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 441, in has_results
return bool(compiler.execute_sql(SINGLE))
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
DatabaseError: Could not load contenttypes.ContentType(pk=29): permission denied for relation django_content_type

我在这里做错了什么?

最佳答案

此数据库的 postgres 用户是自动创建的,我没有检查权限,此数据库缺少权限,因此 GRANT ALL PRIVILEGES ON DATABASE x for user y; 解决了权限问题。我的错。

关于Django loaddata 返回关系被拒绝的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19222373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com