- Python 3.5.x
- Node 4.x
- PostgreSQL 9.4+
- Install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r reqs/development.txt
npm install
- Setup database
createuser -P pythonph
createdb -O pythonph jobsboard
- Create configuration file
cat .env
DEBUG=True
SECRET_KEY=secret
DATABASE_URL=postgres://pythonph:password@localhost/jobsboard
EMAIL_HOST_USER=<YOUR GMAIL EMAIL>
EMAIL_HOST_PASSWORD=<YOUR GMAIL PASSWORD>
- Run migrations
./manage.py migrate
- Create admin user
./manage.py createsuperuser
- Run development server
./manage.py runserver
If you prefer to use docker for development, follow these steps instead.
- Docker Engine
- Docker Compose
- Create configuration file
cat .env
DEBUG=True
SECRET_KEY=secret
DATABASE_URL=postgres://pythonph:password@postgres:5432/jobsboard
EMAIL_HOST_USER=<YOUR GMAIL EMAIL>
EMAIL_HOST_PASSWORD=<YOUR GMAIL PASSWORD>
-
Run migrations and create admin user
docker-compose run --rm -u "$(id -u):$(id -g)" web /bin/bash python3 manage.py migrate python3 manage.py createsuperuser exit
-
Run development server
docker-compose run --rm --service-ports web
We use py.test
as our test runner. It is currently configured to run
the files inside directories named tests
inside the sub-apps.
Example: the tests for the jobsboard.jobs
sub-app are inside
jobsboard/jobs/tests/
py.test
py.test recreates the test DB every time. The time difference will become more noticeable once we have a lot of models in the app.
To get around this, we can add --reuse-db
to skip the db creation step.
Take note that this doesn't reuse the existing DB for the current run, but
for the next one.
py.test --reuse-db
If you introduced new fields or new models and use --reuse-db
when running the
test, you need to add --create-db
so it will recreate the DB that includes
you new fields or models.
py.test --create-db
You may also combine --reuse-db
and --create-db
so that it will create a new DB
for this run, but reuse the test DB in the succeeding runs.
py.test --create-db --reuse-db