Skip to content

Setup Project on MacOS

Bartlomiej Mika edited this page Sep 19, 2017 · 1 revision

HOWTO: Setup Academics Today on MacOS for Development

Description

The goal of this article is to provide step-by-step instructions on how to setup django-academicstoday on your MacOS local machine.

Instructions

Prerequisites

You must have the following applications installed before proceeding. If you are missing any one of these then you cannot begin.

  • Python 3.6
  • brew
  • virtualenv
  • redis
  • PostGres

Installation

The following section explains how to setup the application.

  1. Clone a copy of the project somewhere on your machine, we'll be saving to the following locaiton.
mkdir ~/Developer/AcademicsToday/;
cd ~/Developer/AcademicsToday/
git clone https://github.com/AcademicsToday/academicstoday-django;
cd ~/Developer/AcademicsToday/academicstoday-django
  1. Setup our virtual environment
virtualenv -p python3.6 env
  1. Now lets activate virtual environment
source env/bin/activate
  1. Now lets install the libraries this project depends on.
$ pip install -r requirements.txt

Database Setup

This project uses the PostGres database and as a result requires setup before running. The following instructions are to be run in your PostGres console:

drop database academicstoday_db;
create database academicstoday_db;
\c academicstoday_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE academicstoday_db to django;
ALTER USER django CREATEDB;
ALTER ROLE django SUPERUSER;
-- CREATE EXTENSION postgis;

Environment Variables Setup

You need to make a copy of the sample_env.txt file and fill it in with your own values so academicstoday-django will run.

  1. Duplicate the file.
cd ~/Developer/AcademicsToday/academicstoday-django/academicstoday/academicstoday
cp sample_env.txt .env
  1. Go inside the environment variables.
vi .env
  1. Edit the file to suite your needs.

Run the following commands to populate the database.

cd ../academicstoday/academicstoday-django/academicstoday;
python manage.py makemigrations;
python manage.py migrate_schemas;
python manage.py populate_public;
python manage.py setup_fixtures;
python manage.py populate_site;

Host File Setup

This project is uses django-tenants library and is setup to work with multiple domains. As a result, we will need to bind the address academicstoday.ca to your localhost. To do this follow these instructions.

  1. Update your hosts file to support our applications domain.
sudo vi /etc/hosts
  1. Append to the file...
127.0.0.1       academicstoday.com
127.0.0.1       academicstoday.ca
  1. Refresh the dns on your machine to support our new domains.
dscacheutil -flushcache

Application Setup

The final steps to setup our project is to run the following commands:

cd ~/Developer/AcademicsToday/academicstoday-django/academicstoday;
python manage.py makemigrations;
python manage.py migrate;
python manage.py populate_public;
python manage.py setup_fixtures;
python manage.py populate_site;

Usage

To run the web-app, you’ll need to run the server instance and access the page from your browser.

Start up the web-server:

sudo python manage.py runserver academicstoday.ca:80

And inside another seperate Terminal console, please run:

python manage.py rqworker

Finally, in your web-browser, load up the following url:

http://academicstoday.ca/

Congratulations, you are all setup to run the web-app! Have fun coding!#