django-Views之类视图 (六)

book/urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('',views.IndexView.as_view(),name="index"),
]

book/views.py

from django.views import View
from django.shortcuts import render

class IndexView(View):
    def get(self,request):
        return render(request,"index.html")
原文地址:https://www.cnblogs.com/xiximayou/p/11743284.html