postgresql - How to install PostGIS for Django? -


so i'm following docs , want make sure i'm understanding correctly. https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/postgis/

do create file called migrations.py with:

from django.contrib.postgres.operations import createextension django.db import migrations  class migration(migrations.migration):      operations = [         createextension('postgis'),         ...     ] 

and drop in project directory? , run python manage.py makemigrations ?

still better way ist create extension directly making sql query:

create extension postgis; 

after have navigate project-root (there manage.py file inside) , run python manage.py migrate (since django 1.9 - before v.1.9 first run python manage.py makemigrations , after python manage.py migrate)

but if want use code, have add "models.py". file called "python manage.py migrate"

so models.py looks like:

from django.contrib.gis.db import models django.contrib.postgres.operations import createextension django.db import migrations  class migration(migrations.migration):      operations = [         createextension('postgis'),     ]   class model1(models.model):      geom = models.geometryfield(srid=4326,blank=true,null=true)      name = models.textfield(null=true) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -