【发布时间】:2019-05-09 08:59:33
【问题描述】:
我有一个预先构建的 django 项目,需要在 ubuntu 18 上运行它。使用 postgresql 作为数据库引擎,完成并安装了所有先决条件。为项目创建了一个数据库并添加了具有所需权限的用户,然后将这些设置更新到 settings.py 文件中
然后我运行以下命令来准备迁移并实施它。
# python manage.py makemigrations
No changes detected
&
# python manage.py migrate
Traceback (most recent call last):
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
psycopg2.ProgrammingError: permission denied to create extension "postgis"
HINT: Must be superuser to create this extension.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 77, in handle
connection.prepare_database()
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 26, in prepare_database
cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/hsn/env_banax_api/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: permission denied to create extension "postgis"
HINT: Must be superuser to create this extension.
你们中的任何人都知道如何解决它吗? django 服务器正在运行,但我得到了这个页面,我猜这与数据库连接有关。 附上现在显示的页面截图。
【问题讨论】:
-
不,该屏幕截图与连接无关。它会告诉您问题所在。
-
@DanielRoseman 作为系统管理员该寻找什么?
-
尝试使用 postgres 的超级用户自行在数据库中添加 postgis 扩展
-
@Sanip 我在创建超级用户时也遇到了错误。
-
你的意思是 django 超级用户还是 postgres 超级用户?
标签: django postgresql manage.py django-manage.py