8 Frequently Used Commands in Python Django

Introduction

In this article, I'll cover all the commands that Django, the Python web framework, often handles.

Project creation

$ python manage.py startproject [Project name]

A command to create a Django project.

Add application

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

Start local server

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

Create an administrator account

$ 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).

Start Python interactive mode

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

Start database interactive mode

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

Creation of migration file

$ python manage.py makemigrations

This command adds the migration file required to reflect the database. Often used after adding a schema to models.py.

Database reflection

$ python manage.py migrate

This command is used to reflect the mimicry file to the database. Often you run migrate before running runserver.

in conclusion

I have carefully selected the commands that I often use, but if there are other commands that I often use, please comment.

Recommended Posts

8 Frequently Used Commands in Python Django
Frequently used commands in virtualenv
Summary of frequently used commands of django (beginner)
Summary of frequently used commands in matplotlib
[python] Frequently used techniques in machine learning
pyenv Frequently used commands
Frequently used tmux commands
Frequently used Linux commands
Frequently used Linux commands
Frequently used linux commands
Frequently used pip commands
Code often used in Python / Django apps [prefectures]
Run shell commands in python
[Python] Frequently used library code
Python frequently used code snippets
A collection of commands frequently used in server management
[For beginners] Django Frequently used commands and reference collection
Check for external commands in python
Linux Frequently Used Commands [Personal Memo]
Commands often used in the development environment during Python implementation
[Python] Basic knowledge used in AtCoder
[Linux] Frequently used Linux commands (file operation)
Frequently used Linux commands (for beginners)
List of frequently used Linux commands
[Anaconda3] Summary of frequently used commands
[Linux] Frequently used Linux commands (folder operation)
[Python] A memo of frequently used phrases (by myself) in Python scripts
A class that summarizes frequently used methods in twitter api (python)
Create your own Linux commands in Python
[Linux] Review of frequently used basic commands 2
Disk-related commands often used in Ubuntu (memories)
Python + Selenium Frequently used operation method summary
[Linux] List of Linux commands used in practice
[Linux] Review of frequently used basic commands
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Models in Django
Python Django Tutorial (5)
Python Django Tutorial (2)
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Python Django Tutorial (8)
Python Django Tutorial (6)
Plink in Python
Constant in python
Modules of frequently used functions in Python (such as reading external files)
Lifegame in Python.
FizzBuzz in Python