This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up Your Local Development Environment
Ryan Dailey edited this page May 19, 2017
·
9 revisions
Watch the Video Video Link
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 = True
sudo 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
Install Heroku CLI:
$ sudo apt-get install software-properties-common # debian only
$ sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./"
$ curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install heroku
Add Heroku Remote to Git:
(venv)$ heroku git:remote –a <my Heroku Instance>
Create Database Migrations biased on models:
python manage.py makemigrations
Migrate Models to Database:
python manage.py migrate
Start Server
python manage.py runserver