from django.contrib import admin
from django.urls import path
from demo1.views import fbv_view
urlpatterns = [
path('admin/', admin.site.urls),
path('fbv', fbv_view),
]
from django.shortcuts import render, HttpResponse
def fbv_view(request):
if request.method == "GET":
return HttpResponse('FBV GET...')
else:
return HttpResponse('FBV POST...')
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 注释掉这个东西 ↓ ↓ ↓
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
from django.contrib import admin
from django.urls import path
from demo1.views import CbvView
urlpatterns = [
path('admin/', admin.site.urls),
path('cbv', CbvView.as_view())
]
from django.shortcuts import render, HttpResponse
from django.views import View
class CbvView(View):
def get(self, request):
return HttpResponse('CBV GET...')
def post(self, request):
return HttpResponse('CBV POST...')
def put(self, request):
return HttpResponse('CBV PUT...')
from django.contrib import admin
from django.urls import path
from demo1.views import fbv_view, CbvView
urlpatterns = [
path('admin/', admin.site.urls),
path('fbv', fbv_view),
path('cbv', CbvView.as_view())
]
from django.shortcuts import render, HttpResponse
from django.views import View
def fbv_view(request):
if request.method == "GET":
return HttpResponse('FBV GET...')
else:
return HttpResponse('FBV POST...')
class CbvView(View):
def get(self, request):
return HttpResponse('CBV GET...')
def post(self, request):
return HttpResponse('CBV POST...')
def put(self, request):
return HttpResponse('CBV PUT...')
# 上面的代码不动
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 注释掉这个东西 ↓ ↓ ↓
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
# 下面的代码不动
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!