Listed below are some of the commonly used shell commands while developing web applications in Django:
- Create a project:
$ django-admin startproject <project_name>
- Create an application:
$ python manage.py startapp <app_name>
- Run the development server:
$ python manage.py runserver
- Save changes to models:
$ python manage.py makemigrations <app_name (optional)>
- Create tables in the database according to the database settings for apps in INSTALLED_APPS:
$ python manage.py migrate
- Print SQL script to debug changes:
$ python manage.py sqlmigrate <app_name> 0001
- Check for any problems in the project without making migrations or touching the database:
$ python manage.py check
- Open Django Python shell API:
$ python manage.py shell
- Create super user:
$ python manage.py createsuperuser
- Check Django version:
$ python -m django --version
- Upgrade Django:
$ python -m django --version
- Change the server’s port from the default port 8000
$ python manage.py runserver <port_number>
- Change the server’s IP (example- show work on other computers on the network)
$ python manage.py runserver 0.0.0.0:<port_number>