1.图书管理系统后端接口
1.1 books/models.py 中设置表
from django.db import models
class Books(models.Model):
btitle = models.CharField(max_length=20)
bpub_date = models.DateField()
bread = models.IntegerField()
bcomment = models.IntegerField()
is_delete = models.BooleanField(default=False)
1.2 urls.py 中设置路由
from django.urls import path
from . import views
urlpatterns = [
path('book/', views.BooksView.as_view()),
]
1.3 book/views.py 视图函数
class BooksView(View):
def get(self, request):
books = Books.objects.filter(is_delete=False)
book_list = books.values('id',&#