command
django-admin startproject {Project name}
The following command in the directory where manage.py is located
command
python manage.py startapp {app name}
{app name}/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
Write the URLConf from each application in this urlpatterns
{Project name}/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
{Project name}/settiong.py
LANGUAGE_CODE = 'ja'
TIME_ZONE = 'Asia/Tokyo'
migrate
command ... Creates tables for all required databases according to the database settings in the file
command
python manage.py migrate
command
python manage.py makemigrations {Application name}
You can run make migrations
to tell Django's model that it has changed and save it to reflect the change.
Django Admin is a page where you can edit website information from your browser that only administrators can enter. You can access the admin site, which only the administrator can enter, by creating an admin user.
command
python python manage.py createsuperuser
To start the management server, start the server with python manage.py runserver
.
Then go to the local domain "/ admin /", that is, http://127.0.0.1:8000/admin/.
When you access it, the following screen will be displayed and enter the Username
and Password
created by the admin user.
To be able to edit the app on admin, edit {app name} /admin.py
.
For example, to tell admin that the Question object has an admin interface, write:
{app name}/admin.py
from django.contrib import admin
from .models import Question
admin.site.register(Question)
It's going to be long, so cut it. Continued ⇒ {comming soon}
Recommended Posts