How to Use a PostGIS Geometry With Peewee
It’s easier to do than it looks.
It’s astonishing to me how many people have this problem, and nobody thought to write up a solution to make other people’s searches a little easier. So, here I am, to save you some time with your Peewee and PostGIS adventures.
Let’s get straight to it!
Make sure PostGIS is installed
This might seem trivial. But, when you don’t understand why your solution isn’t working even though you did every step only to realize PostGIS wasn’t installed, then you’d wish you checked it at first. It’s a small check that will save you some time down the road.
If you’re using a tool like PGAdmin with a local installation of PostgreSQL, go to the query tool and type in this command:
CREATE EXTENSION postgis CASCADE;
This call will ensure that every other extension that PostGIS relies on will be installed as well. It will also let you know whether the extension is already there.
The more likely scenario is that you’re using Docker intending to either integrate it into a Kubernetes cluster, or you just don’t want to clutter your system with a DB installation.