django-template/Makefile

39 lines
1.5 KiB
Makefile
Raw Normal View History

2021-04-01 09:58:13 +02:00
.DEFAULT_GOAL := help
help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
2021-07-01 09:32:47 +02:00
lint: ## Check style with black
black --check --exclude="/(postgres|venv|migrations|\.git)/" .
format: ## Format style with black
black --exclude="/(postgres|venv|migrations|\.git)/" .
2021-07-01 09:30:41 +02:00
docker.recreate.django: ## Recreate Django image
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml build --no-cache --force-rm django
docker-compose -f docker-compose.yaml up --force-recreate --no-deps -d django
2021-07-01 09:30:41 +02:00
make run.loaddata
2021-07-01 09:32:47 +02:00
run.makemigrations: ## Makemigrations
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml exec -T django bash -c "python3 manage.py makemigrations"
2021-07-01 09:30:41 +02:00
2021-07-01 09:32:47 +02:00
run.migrate: ## Migrate
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml exec -T django bash -c "python3 manage.py migrate"
2021-07-01 09:30:41 +02:00
2021-07-01 09:32:47 +02:00
run.loaddata: ## Load initial data
2021-07-01 09:30:41 +02:00
# Remove database
rm -rf database.sqlite
# Remove media
rm -rf media
# Migrate
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml exec -T django bash -c "python3 manage.py migrate"
2021-07-01 09:30:41 +02:00
2021-07-01 09:32:47 +02:00
run.loaddata.test: ## Load initial data test
2021-07-01 09:30:41 +02:00
make run.loaddata
# Add superuser: alias "admin" - password "admin"
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml exec -T django bash -c "cat data/create_superuser.py | python3 manage.py shell"
2021-07-01 09:30:41 +02:00
# Add more users: alias random - password "password"
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml exec -T django bash -c "cat data/create_users.py | python3 manage.py shell"
2021-07-01 09:32:47 +02:00
run.server: ## Run server
2022-06-27 14:28:40 +02:00
docker-compose -f docker-compose.yaml up