A cloud-based application used to help entrepreneurs throughout the lifecycle of their businesses.
- Python 3.4
- Postgres 9.4
- pip 8.1
- virtualenv 15.0.0
- Clone the projects.
git clone [email protected]:smegurus/smegurus-django.git
- Init the virtual environment.
OS X
python3 -m venv env
Linux / FreeBSD
virtualenv env
- Now lets activate virtualenv
source env/bin/activate
- Confirm we are using Python3
python --version # Should return Python 3.4+
- OS X USERS ONLY: (a) Check what Postgres.app version you are using. (b) For Postgres we need the following $PATH, so just type it in. If you have a different version installed, please change it the
9.6
version to your current version.
export PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH"
- Install the required Python libraries.
Automatically
Note: Please use this method of installation.
pip install -r requirements.txt
Manually
Note: Use this method if your automatic installation breaks and you need to diagnose the problem. See: requirements.txt
- Load up
pgsql
console.
(OS X)
(Click Applications and click "postgres" icon)
(Linux / FreeBSD)
su pgsql
- Once in the
pgsql
console, write the following commands:
OS X
drop database smegurus_db;
create database smegurus_db;
\c smegurus_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE smegurus_db to django;
ALTER USER django CREATEDB;
ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;
Linux
sudo -i -u postgres
psql
DROP DATABASE smegurus_db;
CREATE DATABASE smegurus_db;
\c smegurus_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE smegurus_db to django;
ALTER USER django CREATEDB;
-- ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;
FreeBSD
su postgres
/usr/local/bin/dropdb smegurus_db;
/usr/local/bin/createdb smegurus_db;
/usr/local/bin/psql smegurus_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE smegurus_db to django;
ALTER USER django CREATEDB;
-- ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;
- Copy our sample .env file to be our new file and open it up:
touch ~/smegurus-django/smegurus/.env
vi ~/smegurus-django/smegurus/.env
-
While inside the
.env
file, please fill it to match your configuration. -
Setup the database.
python manage.py makemigrations; \
python manage.py migrate; \
python manage.py migrate_schemas; \
python manage.py populate_public; \
python manage.py setup_fixtures; \
python manage.py populate_site;
- Setup your root user.
python manage.py createsuperuser;
- Install
redis
.
brew install redis
- Afterwords lets get it started.
brew services start redis
- Confirm it is working by running the following command waiting to get a
PONG
response:
redis-cli ping
-
Congratulations you are now setup.
-
Addendum - Running this command will force
redis
to load up everytime your computer starts up.
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
- Addendum - Running this command will stop
redis
from loading up every time your computer starts up.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
- Go to
hosts
file
sudo vi /etc/hosts
- Add the following:
127.0.0.1 smegurus.co
127.0.0.1 www.smegurus.co
- Restart the DNS:
dscacheutil -flushcache
Before you run the application, you need to load up celery in a separate console terminal:
celery -A smegurus worker -l info;
If you are developing locally from your machine, use this command.
sudo python manage.py runserver smegurus.co:80;
Notes:
- When it asks for your password, use your MacOS password.
This command will run all the unit tests our application has:
python manage.py test
If you want to run all the unit tests for a particular app. Run the following:
python manage.py test api.tests
There are cases where an application may have countless unit tests and you want to run a particular set. Run the following:
python manage.py test api.tests.test_authentication
In your browser, load up: http://smegurus.co
.