- Python 3
- PostgreSQL
- PostGIS
-
Create virtual enviroment
$ virtualenv -p `which python3` venv
-
Start up virtual environment
$ source venv/bin/activate
To exit virtual environment
$ deactivate
-
Install python dependencies
- dev
$ pip install -r requirements/dev.txt
-
Set system locale to utf8
export LC_ALL='en_US.utf8'
Define your own local_settings.py
under smart_campus/smart_campus/settings/
This file will be and should be ignored by git.
The follwoing variables MUST be set up in the setting file.
SECRET_KEY
DATABASES
e.g.
# smart_campus/smart_campus/settings/local_settings.py
from .base import *
SECRET_KEY = 'This is the secret key'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'db_name',
'USER': 'db_user',
'PASSWORD': 'db_pwd',
'HOST': 'localhost',
'PORT': '5432',
},
}
The following envrionment variables MUST be setup.
SECRET_KEY
POSTGRESQL_NAME
POSTGRESQL_USER
POSTGRESQL_PASSWORD
POSTGRESQL_HOST
POSTGRESQL_PORT
DJANGO_SETTINGS_MODULE
e.g.
$ export SECRET_KEY='Some hard to guess value'
$ export POSTGRESQL_NAME='db_name'
$ export POSTGRESQL_USER='user_name'
$ export POSTGRESQL_PASSWORD='user_pwd'
$ export POSTGRESQL_HOST='db_host'
$ export POSTGRESQL_PORT='db_port'
$ export DJANGO_SETTINGS_MODULE="smart_campus.settings.production"
Setup the mail user & password (using gmail in default) in settings/settings.py
EMAIL_HOST_USER
EMAIL_HOST_PASSWORD
Note that you will have to enable 'insecure access' in your gmail account.
python manage.py runserver --settings=smart_campus.settings.local_settings
- Setting up Django and your web server with uWSGI and nginx
- Put your nginx settings file *.conf in /etc/nginx/sites-enabled/
$ uwsgi --ini server-settings/smart_campus.ini
$ sudo killall -s INT uwsgi
$ sudo tail -f /var/log/smartcampus/smartcampus.log
$ cd smart_campus
$ pwd
# smart_campus
$ python3 manage.py initroles
$ python3 manage.py initroles
$ python3 manage.py load_beacon_data [file.xls]
$ pytest
Note that test should be run in root directory instead of smart_campus
.