In this article, I'll cover all the commands that Django, the Python web framework, often handles.
$ python manage.py startproject [Project name]
A command to create a Django project.
$ python manage.py startapp [Application name]
A command to add an application to an existing project. This is effective when you want to divide the source code by function.
$ python manage.py runserver
A command to start a Django project on your local server.
If you do not specify the port number on the command, the port number is automatically set to 8000.
After running, you can see your Django project by visiting http: // localhost: 8000
.
$ python manage.py createsuperuser
A command to create an admin account for your Django project.
After execution, enter the email address
and password
on the terminal.
You can also log in with the admin account created on the Django admin screen (URL: [root URL] / admin).
$ python manage.py shell
A command that executes Python's interactive mode. In addition to investigating the behavior of Python, it may also be used to ** generate and manipulate ** databases for Django projects.
$ python manage.py dbshell
This command executes the interactive mode of the database. You can get the table name and table contents that exist in the Django project database. By default, it launches SQLite interactive mode.
$ python manage.py makemigrations
This command adds the migration file required to reflect the database. Often used after adding a schema to models.py.
$ python manage.py migrate
This command is used to reflect the mimicry file to the database.
Often you run migrate
before running runserver
.
I have carefully selected the commands that I often use, but if there are other commands that I often use, please comment.
Recommended Posts