-
Notifications
You must be signed in to change notification settings - Fork 2
Setting up your local development environment
Install git:
sudo apt-get install git
Download Repository:
git clone https://github.com/PurdueCam2Project/CAM2API
Create Local Settings settings_local.py:
# Django settings for NetworkCamerasAPI project.
import os
print("Imported Local Settings......")
SECRET_KEY = <Replace With Secret Key>
ALLOWED_HOSTS = ['*']
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATIC_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'cam2api',
'USER': 'cam2api',
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': '',
}
}
DEBUG = Truesudo apt-get install
- python-dev
- libpq-dev
- postgresql
- postgresql-contrib
- postgis
- python3-pip
- python3-venv
Switch to postgresql user:
sudo su – postgres
Start postgresql shell:
psql
Create API Database:
postgres=# CREATE DATABASE cam2api;
Create Database User:
postgres=# CREATE USER cam2api WITH PASSWORD ‘123456';
Give user access:
postgres=# GRANT ALL PRIVILEGES ON DATABASE cam2api TO cam2api;
Switch to cam2api database:
postgres=# \connect cam2api;
Add Postgis addon:
postgres-# CREATE EXTENSION postgis;
Exit psql shell:
postgres-# \q
Exit postgres user:
exit
Create venv:
python3 –m venv venv
Start virtualenv
source venv/bin/activate
Upgrade pip:
(venv)$ pip install --upgrade pip
Install packages:
(venv)$ pip install –r requirements.txt
Check Django Version:
(venv)$ which django-admin.py
Create Database Migrations biased on models **:
python manage.py makemigrations
Migrate Models to Database:
python manage.py migrate
Start Server
python manage.py runserver
** If you are getting GEOSException, this is a known bug in this python package, and there is a quick fix. You need to edit function geos_version_info inside site-packages/django/contrib/gis/geos/libgeos.py, where you will replace the line ver = geos_version().decode() with ver = geos_version().decode().split(' ')[0].