/
home
/
liman
/
liman-backend
/
utility
/
province
/
File Upload :
llllll
Current File: //home/liman/liman-backend/utility/province/api.py
from django.http import JsonResponse from rest_framework.response import Response from rest_framework import status from utility.table_engine.src.table_engine import TableEngine from .serializer import CitySerializer from .models import * from rest_framework.views import APIView class ProvinceApiSingle(APIView): @staticmethod def get(request, pk): try: if pk: return Response(CitySerializer(instance=Province.objects.get(pk=pk)).data, status.HTTP_200_OK) else: return Response(status=status.HTTP_404_NOT_FOUND) except Exception as e: response = dict( status="Error-" + str(e), ) return Response(response, status.HTTP_422_UNPROCESSABLE_ENTITY) class ProvinceApi(APIView): @staticmethod def table(request): table_engine = TableEngine(Province.objects, request.bodyDict).init_cols( ["id", "name"]).execute() return JsonResponse(table_engine)
Copyright ©2k19 -
Hexid
|
Tex7ure