- python 3 (as
python, else replace all examplepythoncommands withpython3) - postgres
- Make a directory on your computer for this project to live in:
mkdir wecodeafrica - Change to that directory:
cd wecodeafrica - Clone this repo
git clone https://github.com/wecodeafrica/backend - Alternately, you can fork this repo and then clone your fork.
- Change to the backend directory you just cloned:
cd backend - Create a directory for your static files (normally it will be ignored by git)
mkdir backend/staticfiles
virtualenv --python={PATH_TO_PYTHON3.6} dcmpa
source dcmpa/bin/activatepip install -r requirements.txtIf you get an error, you may need to open the requirements.txt file and replace psycopg2==2.8.2 with psycopg2-binary==2.8.3
-
Create a postgres databse by typing
createdb DcmpaWhen you are ready to exit Postgres, type\qand then Enter -
Create a new user, you can do by by typing
createuser postgres --interactive --pwpromptafter which you will be prompted to create a new user.
-
Copy the example .env file:
cp .env.example .env -
Open the .env file and provide values for every variable with the value of
changeme.nano .env -
Use the username, user password, and database name, for the postgres database you just created in the variables
POSTGRES_DB_NAME,POSTGRES_DB_USER, andPOSTGRES_USER_PASSWORD -
(change the variables)
-
(save the .env file)
-
Set the environmental variables
set -a && source .env && set +a
-
Make a migrations file to change your new database schema:
python manage.py makemigrations -
Make a migrations file to change your new database schema:
python manage.py migrate -
Make yourself a super user:
python manage.py createsuperuser- You will be prompted by Django to create a super user, and you can use these credentials to log into the admin interface (more in next step)
-
collect static, so you can run the django admin. You will run this command when you add or update static files:
python manage.py collectstatic -
Run the server
python manage.py runserver -
Navigate to the django admin:
http://localhost:8000/admin/If you see a login screen, everything worked!
- master branch:- staging branch
- production branch:- production branch; the branch is tagged on each merge to show backend versioning.