I can't remember it easily using django, so I'll leave it as a memorandum. The environment is created on the assumption that it is a Mac.
First, create a project. Take sampleproject as an example.
django-admin startproject sampleproject .
Next, create the app. Let's take sample app as an example.
python3 manage.py startapp sampleapp
Create a folder template to store the html file. The location to create is the same hierarchy as manage.py.
mkdir template
Modify setting.py settings
setting.py
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'sampleapp'
]
Next, set the location of the template folder in setting.py. Describe BASE_DIR and'template'in [] of'DIRS' :.
setting.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR, 'template'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
We will add it gradually.