Django Command Cheat Sheet

This is a list of useful django commands i find being used very often
often you might need to clear the init files and start fresh when making migrations

  find . -path "*/migrations/*.py" -not -name "" -delete
  find . -path "*/migrations/*.pyc"  -delete

When working with python in a docker container you may need to run the django commands through docker, docker-compose or whatever other container orchestrating tools you might be using, so for example with docker and docker-compose

  docker-compose run container-microservice-name python migrate
  docker run container-exact-name python migrate

when making changes to model structure and importing models from packages to make migrations

  python makemigrations
  python migrate

Sometimes you might need to access a python interpreter shell within a django project

  python shell

When you need to create an admin user

  python createsuperuser

Add a Comment

Your email address will not be published. Required fields are marked *