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.
A sample API result would look like: http://134.122.80.13/api/v1/crisis/1/participants/
Collaborate at: slack
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
This will create a pyenv-virtualenv for you and probably place it on your
$ brew install pyenv $ brew install pyenv-virtualenv $ pyenv install 3.7.5 $ eval "$(pyenv init -)" quarantined_backend/$ pyenv virtualenv 3.7.5 env-3.7.5
~/home/<username>/.pyenv/versions/
. You can activate that manually usingor even better:quarantined_backend/$ source ~/.pyenv/versions/env-3.7.5/bin/activate
or, there are better ways to do this if you follow https://github .com/pyenv/pyenv-virtualenvquarantined_backend/$ pyenv activate env-3.7.5
- Now you are in the right environment, install dependencies using:
(env-3.7.5) quarantined_backend/$ pip install -r requirements.txt
- Install
postgis
usingbrew install 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) quarantined_backend/$ 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) quarantined_backend/$ 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:
or even better, run it from pyCharm using your debugger.
(env-3.7.5) quarantined_backend/$ python manage.py migrate (env-3.7.5) quarantined_backend/$ python manage.py collectstatic (env-3.7.5) quarantined_backend/$ python manage.py runserver
-
Fork and clone the repo:
After forking this repo, do
$ git clone git@github.com:<your-username>/quarantined_backend.git $ cd quarantined_backend quarantined_backend/$
-
Create a new environment using venv and activate it:
quarantined_backend/$ python -m venv env-3.7.5 python=3.7.5 (env-3.7.5) quarantined_backend/$ 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) quarantined_backend/$ 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) quarantined_backend/$ 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) quarantined_backend/$ 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) quarantined_backend/$ python manage.py migrate (env-3.7.5) quarantined_backend/$ python manage.py collectstatic (env-3.7.5) quarantined_backend/$ python manage.py runserver
or even better, run it from pyCharm using your debugger
-
Getting this error when running
python manage.py migrate
on Windowsdjango.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 Windowspsycopg2.OperationalError: could not translate host name "DATABASE_HOST" to address: Unknown host
Update quarantined_backend/local_settings.py file. Default configuration is:
- NAME - postgis
- USER - postgres
- PASSWORD - PostgreSQL password set during installation
- HOST - localhost
- PORT - 5432