Here are the list of commands to use in Django.

Some Basic Commands

Run server python manage.py runserver <port: default=8000>


Create new Django project django-admin startproject <project name> <directory> or python -m django startproject <project name>

Create new apps python manage.py startapp <name> <directory>


Migration : propagating changes you make to your models (adding a field, deleting a model, etc.) โ†’ You should think of migrations as a version control system for your database schema

makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.

makemigrations = commits

  1. migrate : Sync the database state with the current set of models and migrations python manage.py migrate [app_label] [migrate_name] โ€œ

  2. makemigrations: Create new migrations on the change detect on models. python manage.py makemigrations [app_label [app_label ...]]

  3. showmigrations: Show all migrations in project. python manage.py showmigrations [app_label [app_label ...]]


Shell

django-admin shell or python manage.py shell

--interface {ipython,bpython,python}, -i `{ipython,bpython,python}

test python manage.py test [test_label [test_label ...]]


These commands are only available if Djangoโ€™s authentication system (django.contrib.auth) is installed.

changepassword django-admin changepassword [<username>]

createsuperuser django-admin createsuperuser