Backend for a wishful quarantine people helper application that would be out soon. Fighting #COVID-19 one step at a time. My wish for this project:
- Lookup people who are ready to help you out when you are quarantined. For buying groceries etc.
- Register yourself as someone who can do these errands.
- A map view with markers and other stuff making it easy for people to access.
API documentation: http://docs.quarantine-help.space/#/
Collaborate at: Slack:Quarantine Help
We use python 3.7.5
for development. Make sure you have this installed on
your machine, or use pyenv
as described later in this documentation.
-
Install pyenv and its virtualenv manager using
$ brew install pyenv $ brew install pyenv-virtualenv $ pyenv install 3.7.5 $ eval "$(pyenv init -)" quarantine-help-api/$ pyenv virtualenv 3.7.5 env-3.7.5
This will create a pyenv-virtualenv for you and probably place it on your
~/home/<username>/.pyenv/versions/
. You can activate that manually usingquarantine-help-api/$ source ~/.pyenv/versions/env-3.7.5/bin/activate
or even better:
quarantine-help-api/$ pyenv activate env-3.7.5
or, there are better ways to do this if you follow Pyenv:Docs
-
Now you are in the right environment, install dependencies using:
(env-3.7.5) quarantine-help-api/$ pip install -r requirements.txt
-
Install
postgis
usingbrew install postgis
. You can create a database and set the user roles using the following commands:CREATE DATABASE quarantined_db; CREATE EXTENSION postgis; ALTER EXTENSION postgis UPDATE; CREATE USER quarantined_user WITH PASSWORD 'ABCD123<changeThis>'; GRANT ALL PRIVILEGES ON DATABASE quarantined_db TO quarantined_user; ALTER ROLE quarantined_user SET timezone TO 'UTC'; ALTER ROLE quarantined_user SET default_transaction_isolation TO 'read committed'; ALTER ROLE quarantined_user SET client_encoding TO 'utf8';
-
We use
pre-commit
hooks to format code. See that you install it using https://pre-commit.com/. Later, install our pre-commit hooks using(env-3.7.5) quarantine-help-api/$ pre-commit install
-
There are some
localsettings
you need to have as part of running the server. You can copy a template using:(env-3.7.5) quarantine-help-api/$ cp quarantined_backend/local_settings_sample.py quarantined_backend/local_settings.py
You need to modify the values there to use the applicaiton in full. -
Run the Django standard runserver steps:
(env-3.7.5) quarantine-help-api/$ python manage.py migrate (env-3.7.5) quarantine-help-api/$ python manage.py collectstatic (env-3.7.5) quarantine-help-api/$ python manage.py runserver
or even better, run it from pyCharm using your debugger.
-
Create a superuser and add some initial data to the database.
(env-3.7.5) quarantine-help-api/$ python manage.py createsuperuser
See that we would need a crises object to start with.
-
Fork and clone the repo: After forking this repo, do
$ git clone [email protected]:<your-username>/quarantine-help-api.git $ cd quarantine-help-api quarantine-help-api/$
-
Create a new environment using venv and activate it:
quarantine-help-api/$ python -m venv env-3.7.5 python=3.7.5 (env-3.7.5) quarantine-help-api/$ env-3.7.5/Scripts/activate
- You will see a folder named env-3.7.5 created
- Here, env-3.7.5 is the environment name and we need the environment to run Python 3.7.5
-
Now you are in the right environment, install the dependencies using:
(env-3.7.5) quarantine-help-api/$ pip install -r requirements.txt
-
Install PostGIS - Reference
-
Download the installer from Enterprise DB
-
Click windows on the EnterpriseDB page and download the appropriate version for your computer (64bit or 32bit)
-
Run the
.exe
that has been downloaded to install PostgreSQL -
The default settings should be good. When prompted enter a password that you can remember
-
PostgreSQL's Application Stack Builder will open after finishing the installation
-
Select PostgreSQL from the dropdown and click next
-
Under "Spatial Extensions" check the most recent version of PostGIS
-
Use default options and after the download finishes click next to start installing
-
Make sure "create spatial database" is checked and change the database name to postgis
-
We use pre-commit hooks to format code. See that you install it using https://pre-commit.com/. Later, install our pre-commit hooks using
(env-3.7.5) quarantine-help-api/$ pre-commit install
-
There are some localsettings you need to have as part of running the server. You can copy a template using:
(env-3.7.5) quarantine-help-api/$ cp quarantined_backend/local_settings_sample.py quarantined_backend/local_settings.py
You need to modify the values there to use the application in full
-
Run the Django standard runserver steps:
(env-3.7.5) quarantine-help-api/$ python manage.py migrate (env-3.7.5) quarantine-help-api/$ python manage.py collectstatic (env-3.7.5) quarantine-help-api/$ python manage.py runserver
or even better, run it from pyCharm using your debugger
-
Install pyenv and its virtualenv manager using
$ sudo apt-get update $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git $ curl https://pyenv.run | bash
add the following lines to your
~/.bashrc
:export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"
continue installing
python-3.7.5
$ pyenv install 3.7.5 $ eval "$(pyenv init -)" quarantine-help-api/$ pyenv virtualenv 3.7.5 env-3.7.5
This will create a pyenv-virtualenv for you and probably place it on your
~/home/<username>/.pyenv/versions/
. You can activate that manually usingquarantine-help-api/$ source ~/.pyenv/versions/env-3.7.5/bin/activate
or even better:
quarantine-help-api/$ pyenv activate env-3.7.5
or, there are better ways to do this if you follow Pyenv:Docs
-
Now you are in the right environment, install dependencies using:
(env-3.7.5) quarantine-help-api/$ pip install -r requirements.txt
-
Install
postgis
usingsudo apt-get install postgis
. You can create a database and set the user roles using the following commands:CREATE DATABASE quarantined_db; CREATE EXTENSION postgis; ALTER EXTENSION postgis UPDATE; CREATE USER quarantined_user WITH PASSWORD 'ABCD123<changeThis>'; GRANT ALL PRIVILEGES ON DATABASE quarantined_db TO quarantined_user; ALTER ROLE quarantined_user SET timezone TO 'UTC'; ALTER ROLE quarantined_user SET default_transaction_isolation TO 'read committed'; ALTER ROLE quarantined_user SET client_encoding TO 'utf8';
-
We use
pre-commit
hooks to format code. See that you install it using https://pre-commit.com/. Later, install our pre-commit hooks using(env-3.7.5) quarantine-help-api/$ pre-commit install
-
There are some
localsettings
you need to have as part of running the server. You can copy a template using:(env-3.7.5) quarantine-help-api/$ cp quarantined_backend/local_settings_sample.py quarantined_backend/local_settings.py
You need to modify the values there to use the applicaiton in full. -
Run the Django standard runserver steps:
(env-3.7.5) quarantine-help-api/$ python manage.py migrate (env-3.7.5) quarantine-help-api/$ python manage.py collectstatic (env-3.7.5) quarantine-help-api/$ python manage.py runserver
or even better, run it from pyCharm using your debugger.
-
Create a superuser and add some initial data to the database.
(env-3.7.5) quarantine-help-api/$ python manage.py createsuperuser
See that we would need a crises object to start with.
You can load fixtures from the folder "fixtures", e.g. quarantine-help-api/$ python manage.py loaddata fixtures/small
You can run the test suite by executing (env-3.7.5) quarantine-help-api/$ python manage.py test
or setting up the
django test configuration to PyCharm.
- Getting this error when running
python manage.py migrate
on Windows:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
-
Install GDAL via OSGeo4W - https://stackoverflow.com/a/49159195/9734484
-
If you are still getting the same error after executing
python manage.py migrate
add gdal version present inC:/OSGeo4W/bin
to libgdal.py file shown in the error stack, for instance, if gdal300.dll is present add "gdal300" to the list,lib_names
under os=="nt" for Windows -
Getting this error when running
python manage.py migrate
on Windows:psycopg2.OperationalError: could not translate host name "DATABASE_HOST" to address: Unknown host
Update
quarantined_backend/local_settings.py
file with the rightDatabase
configurations.