Backend requirements:
- install
pip
-- https://pip.pypa.io/en/stable/installing/#installation - install
virtualenv
-- https://virtualenv.pypa.io/en/stable/installation/#installation - install
virtualenvwrapper
-- https://virtualenvwrapper.readthedocs.io/en/latest/install.html#installation (pip install virtualenvwrapper
) - install and run
PostgreSQL
andRedis
- install
PhantomJS
selenium driver (if you want to run selenium tests)
Ubuntu OS:
- install
libcurl4-openssl-dev
-- https://packages.ubuntu.com/xenial/libcurl4-openssl-dev (sudo apt-get install libcurl4-openssl-dev
) - install
zlib1g-dev
-- https://packages.ubuntu.com/ru/xenial/zlib1g-dev (sudo apt-get install zlib1g-dev
) - install
postgis
-- http://postgis.net/install/ (sudo apt-get install postgis
) - install
libgdal-dev
-- https://packages.ubuntu.com/xenial/libgdal-dev (sudo apt-get install libgdal-dev
) - install
gdal
-- https://pypi.python.org/pypi/GDAL (pip install gdal
)
Create new project, virtualenv and install requirements:
git clone [email protected]:pik-software/<repo>.git <project-name>
cd <project-name>
mkvirtualenv --python=$(which python3.6) <project-name>
pip install -r requirements.txt # install python requirements
Create file settings_local.py
in _project_
and setup DATABASE and some local settings:
DEBUG = True
SECRET_KEY = '0n-w7wsf^3-ehi^!@m2fayppf7cc3k4j5$2($59ai*5whm^l7k'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': '<project-name>',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'localhost',
'PORT': '5432'
}
}
Create and migrate database:
createdb <project-name> # create postgres database
(OR sudo su postgres -c "createdb <project-name>")
python manage.py migrate
Run dev server:
python manage.py runserver
Database transfer with dumpfile:
# The command for create dumpfile (on localhost)
pg_dump -d <project-name> -h localhost -U postgres -W -Fc -x -O > dump.dmp
# The command for restore dump from file (on server)
pg_restore dump.dmp