It is a python web framework, which does not allow us to customize that much and mostly inherited. Templates are given but are not actually needed but rather models, views, and control(logics) are needed! What we're going to make is endpoint, api, data offering api service.
$ conda create -n test03 python=3.8
$ conda env list
It shows a list of virtual environments
$ conda activate test03
$ pip freeze
To see the packages installed in the virtual environment
$ pip install django
$ mkdir practice
It creates a practice app
$ django-admin startproject test03
$ tree
Below is the directory tree when we start project test03
.
├── manage.py
└── test03
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
manage.py is the highest directory of the project.
asgi.py is an asynchronous server gate interface.
wsgi.py is used to connect web server and django framework
urls.py is for server routing.
$ python manage.py runserver
$ python manage.py startapp account
├── account
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── db.sqlite3
├── manage.py
└── test03
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-38.pyc
│ ├── settings.cpython-38.pyc
│ ├── urls.cpython-38.pyc
│ └── wsgi.cpython-38.pyc
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
App is a web application for web log system, publicly recorded database, or opinion polls in a small scale, whereas project is a collection of certain website config and apps. Project can contain multiples of apps. An app can be in multiples of projects.
$ python manage.py makemigrations account
It'll create migrations for 'account'
Migration: Intermediate process to check the history of change in models.py. If there's an mistake found after the database modification, we can't go edit the database, but should modify in models.py. It's basically acting like a git.
$ python manage.py sqlmigrate account 0001
It'll show sql queries
$ python manage.py migrate account 0001