[PYTHON] [Django series] Basic commands

Introduction

I will summarize the commands I have used so far and what I learned when I used it myself.

Explanation and usage of basic commands

① 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.

in conclusion

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.

Reference material

Django Document Table of Contents https://docs.djangoproject.com/ja/3.0/contents/

"Django Migration Summary" https://qiita.com/okoppe8/items/c9f8372d5ac9a9679396

Recommended Posts

[Django series] Basic commands
Basic commands
Basic LINUX commands
Django DB initialization commands
Django commands ignore USE_I18N
Basic commands for file operations
Organize [Django] commands and roles
Basic knowledge of Linux and basic commands
Prevent double launch of django commands
8 Frequently Used Commands in Python Django
Django
Commands for creating SNS with Django
About Linux commands Super basic edition
[Linux] Review of frequently used basic commands 2
Summary of frequently used commands of django (beginner)
Commands for creating a new django project
Basic grammar of Python3 series (list, tuple)
[Linux] Review of frequently used basic commands
(For myself) Django_1 (Basic / Hello World / Template)