22 lines
523 B
Python
22 lines
523 B
Python
import jdatetime
|
|
from rest_framework.pagination import PageNumberPagination
|
|
|
|
|
|
class CustomPagination(PageNumberPagination):
|
|
page_size = 10
|
|
page_size_query_param = 'page_size'
|
|
max_page_size = 100
|
|
|
|
|
|
def convert_to_miladi(year=None, month=None, day=None):
|
|
date = jdatetime.datetime(year, month, day).togregorian()
|
|
return date
|
|
|
|
|
|
def build_query(fields, value):
|
|
from django.db.models import Q
|
|
query = Q()
|
|
for field in fields:
|
|
query |= Q(**{f"{field}__icontains": value})
|
|
return query
|