tuman list api uchun name boyicha search qoshildi
This commit is contained in:
@@ -24,6 +24,15 @@ class DistrictListApiView(generics.GenericAPIView, ResponseMixin):
|
|||||||
|
|
||||||
@swagger_auto_schema(
|
@swagger_auto_schema(
|
||||||
tags=["Admin Districts"],
|
tags=["Admin Districts"],
|
||||||
|
manual_parameters=[
|
||||||
|
openapi.Parameter(
|
||||||
|
in_=openapi.IN_QUERY,
|
||||||
|
type=openapi.TYPE_STRING,
|
||||||
|
name='name',
|
||||||
|
description="tuman nomi bo'yicha qidiruv",
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
],
|
||||||
responses={
|
responses={
|
||||||
200: openapi.Response(
|
200: openapi.Response(
|
||||||
description="Success",
|
description="Success",
|
||||||
@@ -86,8 +95,12 @@ class DistrictListApiView(generics.GenericAPIView, ResponseMixin):
|
|||||||
)
|
)
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
try:
|
try:
|
||||||
|
name = request.query_params.get('name', None)
|
||||||
query = self.queryset.all()
|
query = self.queryset.all()
|
||||||
|
|
||||||
|
if not name is None:
|
||||||
|
query = query.filter(name__istartswith=name)
|
||||||
|
|
||||||
page = self.paginate_queryset(queryset=query)
|
page = self.paginate_queryset(queryset=query)
|
||||||
if page is not None:
|
if page is not None:
|
||||||
serializer = self.serializer_class(page, many=True)
|
serializer = self.serializer_class(page, many=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user