Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
django postgis install
/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
Traceback (most recent call last):
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/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 24, in <module>
execute_from_command_line(sys.argv)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 77, in handle
connection.prepare_database()
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/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 "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/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 "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/harrymoreno/.local/share/virtualenvs/litt-api-HgI9cQzm/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.
# Generated by Django 2.0.3 on 2018-07-18 02:56
import django.contrib.gis.db.models.fields
from django.db import migrations
from django.contrib.postgres.operations import CreateExtension
class Migration(migrations.Migration):
dependencies = [
('polls', '0002_photo'),
]
operations = [
CreateExtension('postgis'),
migrations.AddField(
model_name='event',
name='location',
field=django.contrib.gis.db.models.fields.PointField(null=True, srid=4326),
),
]
> python manage.py makemigrations
> python manage.py migrate
@morenoh149

This comment has been minimized.

Copy link
Owner Author

@morenoh149 morenoh149 commented Jul 18, 2018

solution is to create the extension in the correct db. I had incorrectly created the extension in the default db for superuser.

@ShedrackGodson

This comment has been minimized.

Copy link

@ShedrackGodson ShedrackGodson commented Aug 12, 2020

This worked for me
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment