Fetch field in modal with foreign key relationship

class Service(models.Model):

Clinic = models.ForeignKey(

    Shop, on_delete=models.CASCADE, null=True, blank=True, related_name="service")

Doctor = models.ForeignKey(

    Doctor, on_delete=models.CASCADE, null=True, blank=True)

Fees = models.IntegerField()

class Meta:

    unique_together = (('Clinic', 'Doctor'),)

@property

def get_name(self):

    return self.Clinic.Name + "--" + self.Doctor.Name

def __str__(self):

    return self.get_name

class ServiceDetailsDay(models.Model):

ServiceID = models.ForeignKey(

    Service, on_delete=models.CASCADE, null=True, blank=True, related_name="serviceday")

Day = models.CharField(max_length=10, choices=week_days, null=True)

class Meta:

    unique_together = (('ServiceID', 'Day'),)

@property

def get_name_day(self):

    return self.ServiceID.get_name + "--" + str(self.Day)

def __str__(self):

    return self.get_name_day

class ServiceDetailsDayTime(models.Model):

ServiceDetailsDayID = models.ForeignKey(

    ServiceDetailsDay, on_delete=models.CASCADE, null=True, blank=True, related_name="servicetimes")

Time = models.TimeField()

Visit_capacity = models.IntegerField()

class Meta:

    unique_together = (('ServiceDetailsDayID', 'Time'),)

@property

def get_service_id(self):

    return self.ServiceDetailsDayID.ServiceID.id

def __str__(self):

    return self.ServiceDetailsDayID.get_name_day + "--" + str(self.Time)

In modal for book appointment I had shown name of clinic as well as that particular doctor and day on which he is available, now i have to fetch time of the day on which he is available from model servicedetailsdaytime. how to fetch time related to particular clinic+doctor+day in modal

To clarify, are you saying that you have a modal form being displayed in the browser, and you want that form to be updated with data being retrieved from the ServiceDetailsDayTime model?
(If that’s not what you mean, please clarify)

If so, then you’ll need to add an AJAX call to your modal form to call a view on the server to retrieve that data, using the returned values to update that form.

(Side notes: When posting code here, please enclose the blocks of code between lines of three backtick - ` characters. That means you’ll have a line of ```, then the code, then another line of ```. This forces the forum software to keep that code properly formatted, which is critical with Python.
Also, please try to remove excess blank lines. Trying to read double-spaced code on this forum is very difficult.)