I will summarize the commands I have used so far and what I learned when I used it myself.
① Create a project with Django
django-admin startproject config
The name of the project is arbitrary, but it will be confusing, so we will name it "config" by setting the original settings of the application.
② Create an application with Django
python manage.py startapp home
Next is the creation of the application, but this is also set as "home" in the sense that it manages the origin of the application.
③ Start and stop the server
python manage.py runserver
ctrl c
When starting the server, basically make two terminal screens. We will make it possible to compare and examine when an error occurs.
③ Database operation
python manage.py makemigrations
A command that automatically creates and manages database definitions. Do not use it blindly unless there is a change.
python manage.py migrate
A command that applies a database-defined migration file to a database. This is also a command to be applied when there is a change.
You can read more about the structure and commands in the article "Django Migration Summary".
④ Create an administrator
python manage.py createsuperuser
Once you enter your email address and password, you're done creating your account. I often use the administrator screen when I want to check the contents of the database or when checking in a test.
This time, I briefly summarized how to use the command when I am using it. Official Information "Django Document Table of Contents" Has more details, so beginners may want to refer to it.
Django Document Table of Contents https://docs.djangoproject.com/ja/3.0/contents/
"Django Migration Summary" https://qiita.com/okoppe8/items/c9f8372d5ac9a9679396
Recommended Posts