Skip to content
Brian Fuchs edited this page Mar 25, 2015 · 19 revisions

###Prerequisites###

  • Install Python; it works with Python 2.7, 3.2 or 3.3.
  • Install Django >= 1.6.5 by using the following command:

sudo pip install Django==1.6.5

###Getting the Code### To get a local copy of the repository in a folder named CitizenGrid, type:

git clone https://github.com/ImperialCollegeLondon/citizengrid.git CitizenGrid

###Download Dependencies ### Install following additional packages.

[NOTE: if you are installing on OSX, and get this error

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

you may need to run pip as follows:

ARCHFLAGS=-Wno-error=unused-command-line-argunt-hard-error-in-future pip install some_module

]

sudo pip install djangorestframework [JMS: pip install djangorestframework==2.4.4 to get correct version]

sudo pip install markdown

sudo pip install django-filter

sudo pip install sorl-thumbnail

sudo pip install django-sekizai

sudo pip install django-mptt

sudo pip install django_nyt

sudo pip install django-password_reset

sudo pip install PIL [JMS needed pillow not PIL]

sudo pip install python-dev [JMS can't do] [should this be apt-get? bcf]

sudo pip install python-numpy

sudo pip install PyCrypto

sudo pip install simplejson

sudo pip install boto

sudo pip install Pillow

###Initial Settings### Set Different setting variables such as ALLOWED HOST, ADMINS, DEFAULT_FROM_EMAIL, EMAIL_PORT, MANAGERS, TIME ZONE, MEDIA_ROOT, MEDIA_URL, etc. in dashboard/citizengrid/settings/base.py

###DB Setup### For Sqlite database setup:

python manage.py migrate

Once database file is created, one need to insert applications possible branches, categories and subcategories in respective files. The example branches, categories and subcategories can be entered in the database using the following command.

cd CitizenGrid/prototype-citizengrid/

python manage.py dbshell

[JMS: don't think 'load data infile' is valid in sqlite? How about .import <from_file> <to_table>?]

sqlite >> LOAD DATA INFILE ‘./dbsetup/citizengrid_branch.csv' INTO TABLE citizengrid_branch FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

sqlite >> LOAD DATA INFILE ‘./dbsetup/citizengrid_category.csv' INTO TABLE citizengrid_category FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

sqlite >> LOAD DATA INFILE ‘./citizengrid_subcategory.csv' INTO TABLE citizengrid_subcategory FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

For MySQL and PostgreSQL, have a look on advance setting on this page.

After setting up the database, change the database settings in dashboard/citizengrid/settings/dev.py to whatever suites your db engine, db name, username, and password.

###Deployment on Local Server###

cd CitizenGrid/prototype-citizengrid/

python manage.py runserver

This command run CitizenGrid server on http://localhost:8000

###Advance Settings###

If you’re going to use PostgreSQL or MySQL, make sure you’ve created a database before the DB setup. Do that with “CREATE DATABASE database_name;” within your database’s interactive prompt. For example, in MySQL:

MySQL >> CREATE DATABASE database_name -u username -p password;

If you’re using SQLite, you don’t need to create anything beforehand - the database file will be created automatically when it is needed.

###Frequently Encountered Errors###