Skip to content

Instantly share code, notes, and snippets.

@abdulrehmanch
Last active March 10, 2020 13:03
Show Gist options
  • Save abdulrehmanch/0cf4a9f52cbeb626b85c3f9629e218e4 to your computer and use it in GitHub Desktop.
Save abdulrehmanch/0cf4a9f52cbeb626b85c3f9629e218e4 to your computer and use it in GitHub Desktop.
GeoDjango configuration on Windows

WSL (WINDOWS SUBSYSTEM LINUX)

Step 1: Install Ubuntu from Microsoft Store (18 LTR).
Step 2: Setup environment as below.
Step 3: Setup Pycharm Debug environment from WSL
Reference
https://www.jetbrains.com/help/pycharm/using-wsl-as-a-remote-interpreter.html

GDAL ENV

sudo apt update
sudo apt upgrade # if you already have gdal 1.11 installed
sudo apt install gdal-bin python-gdal python3-gdal # if you don't have gdal 1.11 already installed
sudo apt-get install binutils libproj-dev


Python and VENV installation

Step 1: Update your repositories
sudo apt-get update

Step 2: Install pip for Python 3
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
sudo apt install python3-pip

Step 3: Use pip to install virtualenv
sudo pip3 install virtualenv

Step 4: Launch your Python 3 virtual environment, here the name of my virtual environment will be env3
virtualenv -p python3 env3

Activate your new Python 3 environment. There are two ways to do this
. env3/bin/activate or source env3/bin/activate which does exactly the same thing


Database

sudo apt update

sudo apt install postgresql postgresql-contrib postgis
If not work simultaneously
sudo apt-get install postgis

sudo -i -u postgres and psql
or sudo -u postgres psql

sudo -u postgres createuser --interactive --pwprompt

CREATE ROLE admin WITH LOGIN ENCRYPTED PASSWORD 'admin123';

createdb -O user dbname

psql -d mmd

CREATE EXTENSION postgis;
SELECT PostGIS_version();

Update Postgres config file to access form django
sudo vim /etc/postgresql/10/main/pg_hba.conf
and allow access see reference bellow
PostgreSQL config
https://dzone.com/articles/setting-up-a-postgresql-database-on-an-ubuntu-inst

sudo service postgresql restart

References

POSTGIS and GDAL
https://mothergeo-py.readthedocs.io/en/latest/development/how-to/gdal-ubuntu-pkg.html

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