Management commands used in this chapter
In this chapter, we have introduced a variety of Django management commands. You need to get familiar with them, as they will be used often throughout the book. Let’s revisit the commands we have covered in this chapter.
To create the file structure for a new Django project named mysite
, we used the following command:
django-admin startproject mysite
To create the file structure for a new Django application named blog
:
python manage.py startapp blog
To apply all database migrations:
python manage.py migrate
To create migrations for the models of the blog
application:
python manage.py makemigrations blog
To view the SQL statements that will be executed with the first migration of the blog
application:
python manage.py sqlmigrate blog 0001
To run the Django development server:
python manage.py runserver
To run the development server specifying host/port and settings file:
python manage.py runserver 127.0.0.1:8001 --settings=mysite.settings
To run the Django shell:
python manage.py shell
To create a superuser using the Django authentication framework:
python manage.py createsuperuser
For the full list of available management commands, check out https://docs.djangoproject.com/en/5.0/ref/django-admin/.