Skip to content

Instantly share code, notes, and snippets.

@mebaysan
Last active June 16, 2022 17:14
Show Gist options
  • Save mebaysan/0336c05da98ff3a9349bfda5970a5cfe to your computer and use it in GitHub Desktop.
Save mebaysan/0336c05da98ff3a9349bfda5970a5cfe to your computer and use it in GitHub Desktop.
A sample Makefile for Django projects
.PHONY: help
help:
@echo "{{ project_name }} Projects"
@echo "~~~~~~~~~~~~~~~"
@echo ""
@echo "check : Health check"
@echo "coverage : Make test coverage"
@echo "docup : Run docker compose services"
@echo "docdown : Stop docker containers"
@echo "migrations : Make django migrations"
@echo "install : Install python requirements"
@echo "recover : docdown + docup + wait + migrations + loaddata"
@echo "runserver : Run django server in debug mode"
@echo "run_gunicorn : Run django server with gunicorn"
@echo "static : Collect static files"
@echo "superuser : Create django super user"
@echo "test : Start django test runner"
@echo "translation : Translation operation"
@echo "wait : Wait for 3 seconds"
@echo ""
check:
@python manage.py check
coverage:
@coverage run --source='.' manage.py test
@coverage report -m
@coverage html
@coverage xml
docup:
@docker-compose up -d --build
docdown:
@docker-compose down -v
dumpdata:
@python manage.py dumpdata {{ [app_names] }} -o dummy.json
loaddata:
@python manage.py loaddata dummy.json
migration:
@python manage.py makemigrations
@python manage.py migrate
install:
@pip3 install -r requirements.txt
recover: install docdown docup wait migration loaddata
@echo "\n\t~~~~~~~~~~~~~~~"
@echo "\tusername: admin"
@echo "\tpassword: 123"
@echo "\t~~~~~~~~~~~~~~~\n"
recover_refactor: install docdown docup wait migration superuser
@echo "\n\t~~~~~~~~~~~~~~~"
@echo "\tusername: admin"
@echo "\tpassword: 123"
@echo "\t~~~~~~~~~~~~~~~\n"
runserver:
@python manage.py runserver 127.0.0.1:8000
run_gunicorn:
@gunicorn {{app_name}}.wsgi -b 0.0.0.0:8000
collect:
@python manage.py collectstatic
superuser:
@python manage.py createsuperuser
tests:
@python manage.py test
translation:
@python manage.py makemessages -l tr
@python manage.py compilemessages
wait:
@sleep 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment