This is a sample project used as a base for django related projects.
To run django locally you need python version to 3.11.3
and pipenv, you can use pyenv to set your desired python version.
Django needs postgres and redis container to be up and running, to do so clone the project, enter in the project folder and hit:
docker compose up postgres redis
inside the project folder make sure you use python 3.11.3
python --version
you should see
Python 3.11.3
install requirements (listed inside Pipfile
) by
pipenv install
To run tests you will need also dev dependencies
pipenv install --dev
Create a .env
file using the .env.example
file and changing the url to be localhost
in the following env variables
POSTGRES_HOST
REDIS_URL
Your .env
file should be something like this
#django
ENV=dev
DJANGO_DEBUG=True
SECRET_KEY='supersecretkey'
#db
POSTGRES_USER=postgres
POSTGRES_DB=app_db
POSTGRES_HOST=localhost
POSTGRES_PASSWORD=password
POSTGRES_PORT=5432
#redis
REDIS_URL=redis://localhost:6379/0
Once done enter inside your pipenv virtual environment by
pipenv shell
Run migrations with
python manage.py migrate
Or (if you have make
installed) by
make migrate
Everything is done! You can now start the server with
python manage.py runserver
Or
make run-dev
This apps gather data from Public Holiday API via a django command, you can populate PublicHoliday models with
python manage.py populate_models
Or
make populate-models
For each command run a random country is selected and all the public holidays for that country would be fetched and stored in the db
Testing requirements can be installed by
pipenv install --dev
To run the ruff linter on your codebase hit
make lint
pre-commit (that in turn will run ruff check) can be installed as well with
pre-commit install
You can run django tests by simply run
pytest
To simulate the testing pipeline in CircleCI just run
docker compose run django ci