این کد ویو منه
from django.shortcuts import render
from rest_framework import viewsets, status, permissions
from .models import RegisterVisits
from .serializers import RegisterVisitsSerializer, CityValidatorSerializer
from app_medicalCenters.models import MedicalCenterInfo, City
from rest_framework.decorators import action
from rest_framework.response import Response
import jdatetime



def set_data_dic(data):

    if isinstance(data, dict):
        body_data = data
    else:
        body_data = data.dict()

    return body_data

class VisitViewSet(viewsets.ViewSet):
    permission_classes = [permissions.IsAuthenticated]

    @action(detail=False, methods=['get'])
    def get_config_visits_medical_center(self, request):
        medical_center_id = request.query_params.get('medical_center_id', None)
        if medical_center_id:
            visits = RegisterVisits.objects.filter(medical_center_id=medical_center_id)
        else:
            visits = RegisterVisits.objects.all()
        
        response_data = []
        for visit in visits:
            data_dic_for_Set = {
                "id": visit.id,
                "doctor": visit.doctor.user.first_name + " " + visit.doctor.user.last_name,  # Use the correct attribute for doctor's name
                "date": visit.visit_date.strftime("%Y/%m/%d"),
                "date_p": jdatetime.date.fromgregorian(date= visit.visit_date).strftime("%Y/%m/%d"),
                "start_time": visit.starttime.strftime("%H:%M"),  # Example detail, you can customize it
                "end_time": visit.endtime.strftime("%H:%M"),  # Example detail, you can customize it
            }
            response_data.append(data_dic_for_Set)
        return Response(response_data, status=status.HTTP_200_OK)
    
    @action(detail=False, methods=['get'])
    def get_config_visits_doctor(self, request):
        visits = RegisterVisits.objects.filter(doctor__user=request.user)
        
        response_data = []
        for visit in visits:
            date_data = visit.visit_date
            data_dic_for_Set = {
                "id": visit.id,
                "treatmentCenter": visit.medical_center.name_medical_center,
                "date": date_data,
                "date_p": jdatetime.date.fromgregorian(date=jdatetime.date(date_data.year, date_data.month, date_data.day)),
                "startTime": visit.starttime,
                "endTime": visit.endtime,
                "averageVisitTime": visit.time_each_visit,
                "totalVisits": visit.allow_internet_turn + visit.allow_manualt_turn,
                "onlineVisits": visit.allow_internet_turn,
                "manualVisits": visit.allow_manualt_turn
                }
            response_data.append(data_dic_for_Set)
        print(response_data)
        return Response(response_data, status=status.HTTP_200_OK)

    @action(detail=False, methods=['post'])
    def create_visit(self, request):
        body_data = set_data_dic(request.data)
        visit_serializer = RegisterVisitsSerializer(data=body_data)
        if visit_serializer.is_valid():
            visit_serializer.save()
            return Response(visit_serializer.data, status=status.HTTP_201_CREATED)
        return Response(visit_serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    @action(detail=False, methods=['get'])
    def list_visits(self, request):
        city_name = request.query_params.get('city', None)
        if city_name:
            visits = RegisterVisits.objects.filter(city__name=city_name)
        else:
            visits = RegisterVisits.objects.all()
        
        response_data = []
        for visit in visits:
            data_dic_for_Set = {
                "id": visit.id,
                "doctor": visit.doctor.user.first_name + " " + visit.doctor.user.last_name,  # Use the correct attribute for doctor's name
                "specialty": [specialty.name for specialty in visit.doctor.specialties.all()],
                "medicalCenter": visit.medical_center.name_medical_center,
                "appointmentDate": jdatetime.date.fromgregorian(date= visit.visit_date).strftime("%Y/%m/%d"),
                "appointmentTime": visit.starttime.strftime("%H:%M"),
                "details": visit.doctor.description,  # Example detail, you can customize it
                "province": visit.city.province.name,
                "city": visit.city.name
            }
            response_data.append(data_dic_for_Set)
        return Response(response_data, status=status.HTTP_200_OK)




اینم مدل منه
from django.db import models
from app_doctors.models import DoctorsInfo
from app_medicalCenters.models import MedicalCenterInfo
from app_medicalCenters.models import City
from app_patients.models import PatientsInfo


class RegisterVisits(models.Model):
    doctor = models.ForeignKey(
        DoctorsInfo,
        on_delete=models.SET_NULL,
        null=True,
        blank=True,
        verbose_name="پزشک معالج"
    )

    medical_center = models.ForeignKey(
        MedicalCenterInfo,
        on_delete=models.SET_NULL,
        null=True,
        blank=True,
        verbose_name="مرکز درمانی"
    )

    allow_internet_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="حدمجاز نوبت اینترنتی"
    )

    allow_manualt_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="حدمجاز نوبت دستی"
    )

    allow_organization_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="حدمجاز نوبت سازمانی"
    )

    exist_internet_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="موجودی نوبت اینترنتی"
    )

    exist_manualt_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="موجودی نوبت دستی"
    )

    exist_organization_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="موجودی نوبت سازمانی"
    )

    reserved_internet_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="رزروشده نوبت اینترنتی"
    )

    reserved_manualt_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="رزروشده نوبت دستی"
    )

    reserved_organization_turn = models.IntegerField(
        default=0,
        blank=True,
        null=True,
        verbose_name="رزروشده نوبت سازمانی"
    )

    quota_internet_turn = models.FloatField(
        default=50,
        blank=True,
        null=True,
        verbose_name="سهمیه نوبت اینترنتی"
    )

    quota_manualt_turn = models.FloatField(
        default=50,
        blank=True,
        null=True,
        verbose_name="سهمیه نوبت دستی"
    )

    quota_organization_turn = models.FloatField(
        default=0,
        blank=True,
        null=True,
        verbose_name="سهمیه نوبت سازمانی"
    )

    allow_insurance_organization_turn = models.CharField(
        max_length=255,
        blank=True,
        null=True,
        verbose_name="بیمه های مجاز سهمیه سازمانی"
    )

    visit_date = models.DateField(
        verbose_name="تاریخ ویزیت"
    )

    status = models.BooleanField(
        default=False,
        verbose_name = 'وضعیت شیفت'
    )

    starttime = models.TimeField(
        verbose_name="ساعت شروع ویزیت"
    )

    endtime = models.TimeField(
        verbose_name="ساعت پایان ویزیت"
    )

    time_each_visit = models.FloatField(
        default=15,
        verbose_name = 'زمان تقریبی هر ویزیت'
    )

    class Meta:
        db_table = 'tbl_register_visits'
        verbose_name_plural = 'ثبت ویزیت ها'

class PatientReservedVisits(models.Model):
    patient = models.ForeignKey(
        PatientsInfo,
        on_delete=models.CASCADE,
        verbose_name="بیمار"
    )
    visit = models.ForeignKey(
        RegisterVisits,
        on_delete=models.CASCADE,
        verbose_name="ویزیت"
    )
    reservation_add_time = models.TimeField(
        auto_now_add=True,
        verbose_name="زمان اضافه کردن تایم رزرو"
    )
    reservation_time = models.TimeField(
        verbose_name="تایم رزرو"
    )
    status = models.CharField(
        max_length=50,
        choices=[
            ('reserved', 'رزرو شده'),
            ('cancelled', 'لغو شده'),
            ('completed', 'تکمیل شده')
        ],
        default='reserved',
        verbose_name="وضعیت"
    )

    def __str__(self):
        return f"{self.patient} - {self.visit} - {self.status}"

    class Meta:
        db_table = 'tbl_patient_reserved_visits'
        verbose_name_plural = 'ویزیت‌های رزرو شده بیمار'


اینم ارور منه

System check identified 1 issue (0 silenced).
February 18, 2025 - 08:27:56
Django version 5.0.3, using settings 'web_config.settings'
Starting ASGI/Daphne version 4.1.2 development server at http://127.0.0.1:2222/
Quit the server with CTRL-BREAK.
[{'id': 6, 'treatmentCenter': 'بیمارستان شریعتی', 'date': datetime.date(2025, 2, 18), 'date_p': jdatetime.date(1403, 11, 30), 'startTime':
 datetime.time(8, 0), 'endTime': datetime.time(12, 0), 'averageVisitTime': 15.0, 'totalVisits': 15, 'onlineVisits': 10, 'manualVisits': 5}
, {'id': 13, 'treatmentCenter': 'بیمارستان میلاد', 'date': datetime.date(2025, 2, 19), 'date_p': jdatetime.date(1403, 12, 1), 'startTime':
 datetime.time(12, 0), 'endTime': datetime.time(16, 0), 'averageVisitTime': 15.0, 'totalVisits': 30, 'onlineVisits': 20, 'manualVisits': 1
0}]
Internal Server Error: /TakingTurns/visits/get_config_visits_doctor/
Traceback (most recent call last):
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\asgiref\sync.py", line 518, in thread_handler
    raise exc_info[1]
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\django\core\handlers\exception.py", line 42, in inner
    response = await get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\asgiref\sync.py", line 518, in thread_handler
    raise exc_info[1]
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\django\core\handlers\base.py", line 284, in _get_response_async
    response = await sync_to_async(
               ^^^^^^^^^^^^^^^^^^^^
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\asgiref\sync.py", line 468, in __call__
    ret = await asyncio.shield(exec_coro)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\Tabiban_New\Back\.venv\Lib\site-packages\asgiref\current_thread_executor.py", line 40, in run
  File "C:\Program Files\Python311\Lib\json\encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type date is not JSON serializable
HTTP GET /TakingTurns/visits/get_config_visits_doctor/ 500 [0.08, 127.0.0.1:14977]        
HTTP GET /account/profile/check_access_member/ 200 [0.02, 127.0.0.1:14979]
HTTP GET /medicalCenters/MedicalCenters/get_medical_center/ 200 [0.02, 127.0.0.1:14981]   
HTTP GET /medicalCenters/MedicalCenters/get_medical_center/ 200 [0.03, 127.0.0.1:14981]