Beispiel #1
0
 def post(self, request, pk):
     school = get_object_or_404(School, pk=pk)
     serializer = SchoolSerializer(school, data=request.data)
     if not serializer.is_valid():
         return Response({'serializer': serializer, 'school': school})
     serializer.save()
     return redirect('school-list')
Beispiel #2
0
 def post(self, request):
     serializer = SchoolSerializer(data=request.data)
     if not serializer.is_valid():
Beispiel #3
0
 def get(self, request):
     serializer = SchoolSerializer()
Beispiel #4
0
 def get(self, request, pk):
     school = get_object_or_404(School, pk=pk)
     serializer = SchoolSerializer(school)
     return Response({'serializer': serializer, 'school': school})
Beispiel #5
0
 def post(self, request):
     serializer = SchoolSerializer(data=request.data)
     if not serializer.is_valid():
         return Response({'serializer': serializer})
     serializer.save()
     return redirect('school-list')
Beispiel #6
0
 def get(self, request):
     serializer = SchoolSerializer()
     return Response({'serializer': serializer})
Beispiel #7
0
    template_name = 'school_list.html'

    def get(self, request):
        queryset = School.objects.all()
        return Response({'schools': queryset})




class SchoolDetail(APIView):
    renderer_classes = [TemplateHTMLRenderer]
    template_name = 'school_detail.html'

    def get(self, request, pk):
        school = get_object_or_404(School, pk=pk)
        serializer = SchoolSerializer(school)
        return Response({'serializer': serializer, 'school': school})

    def post(self, request, pk):
        school = get_object_or_404(School, pk=pk)
        serializer = SchoolSerializer(school, data=request.data)
        if not serializer.is_valid():
            return Response({'serializer': serializer, 'school': school})
        serializer.save()
        return redirect('school-list')
class SchoolForm(mixins.ListModelMixin,
                  mixins.CreateModelMixin,
                  generics.GenericAPIView):
    queryset = School.objects.all()

    renderer_classes = [TemplateHTMLRenderer]