Notes for yourself Updated from time to time
** I just need to know myself, so the terms may be wrong in some places **
--Conditions --get and post are managed by view class --URL is managed by each app
 
 
In the terminal pip install django

In the terminal move cd to the directory where you want to create the project django-admin startproject any project name
In the terminal python manage.py startapp any app name

 
プロジェクトのurls.py
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
    path('admin/', admin.site.urls),
    path('sns/',include('sns.urls')),
]
アプリのurls.py
from django.urls import path
from . import views
from .views import SnsView
urlpatterns = [
    path('',SnsView.as_view(),name='index'),
]
Add app to settings.py Project folder \ project name \ settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'sns_app' #Add app
]
App \ templates \ App name
Create a template in
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import TemplateView
class SnsView(TemplateView):
    def get(self,request):
        self.params={}
        return render(request,'sns/index.html',self.params)
Recommended Posts