Setup Project on MacOS
The goal of this article is to provide step-by-step instructions on how to setup django-academicstoday on your MacOS
local machine.
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
The following section explains how to setup the application.
- 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
- Setup our virtual environment
virtualenv -p python3.6 env
- Now lets activate virtual environment
source env/bin/activate
- Now lets install the libraries this project depends on.
$ pip install -r requirements.txt
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;
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.
- Duplicate the file.
cd ~/Developer/AcademicsToday/academicstoday-django/academicstoday/academicstoday
cp sample_env.txt .env
- Go inside the environment variables.
vi .env
- 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;
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.
- Update your hosts file to support our applications domain.
sudo vi /etc/hosts
- Append to the file...
127.0.0.1 academicstoday.com
127.0.0.1 academicstoday.ca
- Refresh the dns on your machine to support our new domains.
dscacheutil -flushcache
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;
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!#