Sử dụng APIView, Phân tích mã nguồn Request và Serializer trong Django REST Framework

Sử dụng cơ bản của APIView ============= 1.1 Sử dụng View + JsonResponse from django.http import JsonResponse from .models import Book class BookView(View): def get(self, request): books = Book.objects.all() result = [] for book in books: result.append({'tieu_de': book.name, 'gia': book.price, 'nha_xua ...

Đăng vào ngày 19 tháng 6 lúc 20:23

Phân tích mã nguồn Django REST Framework: Hệ thống view và định tuyến

Hệ thống view trong Django REST Framework Hệ thống view trong Django REST Framework được tổ chức theo cấu trúc phân cấp như sau: rest_framework.views: View cơ bản (APIView) rest_framework.generics: View công cụ (GenericAPIView) rest_framework.mixins: Bộ công cụ view (Create/Destroy/List/Retrieve/Update) rest_framework.viewsets: ViewSet AP ...

Đăng vào ngày 26 tháng 5 lúc 03:00