Второй этап
This commit is contained in:
1 parent
b02fa66f41
commit
a0edc64f1c
25 files changed
+97
-56
No files matched your search
@@ -0,0 +1,8 @@
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
|
||||
class GeneralVacationSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = GeneralVacation
|
||||
fields ='__all__'
|
||||
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('generalvacation/', GeneralVacationAPIView.as_view(), name='generalvacation'),
|
||||
]
|
||||
@@ -1,3 +1,17 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.response import Response
|
||||
import datetime
|
||||
from .serializers import *
|
||||
from .models import *
|
||||
|
||||
# Create your views here.
|
||||
from rest_framework.views import APIView
|
||||
|
||||
class GeneralVacationAPIView(APIView):
|
||||
def get(self, request):
|
||||
general = GeneralVacation.objects.all()
|
||||
|
||||
# Сериализуем извлечённый набор записей
|
||||
serializer_for_basecrit = GeneralVacationSerializer(
|
||||
instance=general, # Передаём набор записей
|
||||
many=True # Указываем, что на вход подаётся именно набор записей
|
||||
)
|
||||
return Response({"Отпуск": serializer_for_basecrit.data})
|
||||
Reference in new issue
Block a user