I will explain from creating a project with Django to initial setting ^ _ ^
Python 3.7.6 Django 3.0.5
First, change to the directory for creating the project. Therefore, create a project as shown below. At this time, the project name will be arbitrary, but this time it will be webproject. If you check the inside of the folder, you can see that manage.py is included.
ChisakinoMacBook-Pro:webapp Chisaki$ django-admin startproject webproject .
ChisakinoMacBook-Pro:webapp Chisaki$ ls
manage.py webproject
Next, add folders as shown below. In this case as well, the name of the folder will be arbitrary, but this time it will be webapp.
ChisakinoMacBook-Pro:webapp Chisaki$ python3 manage.py startapp webapp
ChisakinoMacBook-Pro:webapp Chisaki$ ls
manage.py webapp webproject
Then add more folders for the template. This folder name can be arbitrary, but this time it will be templates.
ChisakinoMacBook-Pro:webapp Chisaki$ mkdir templates
ChisakinoMacBook-Pro:webapp Chisaki$ ls
manage.py templates webapp webproject
The rough folder in the initial state looks like this ^ _ ^
Next is the editor settings! Open setting.py. This time, enter the folder name you added on the 40th line here. Let's add webapp.
Next, add the template folder you added to the 58th line like an image.
Next, move to urls.py in the web project. Describe as follows. Don't forget to add include on the second line at this time.
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('webapp.urls')),
]
Next, create urls.py directly under webapp. Then write as follows. This file will be used by connecting URLs in the future.
from django.urls import path
urlpatterns = [
path('', ),
]
The above is the explanation from Django project creation to initial setting! Please refer to it ^ _ ^
Recommended Posts