Change value in queryset

In Django simple app I have model Activity

Class Activity(models.Model):
    class Meta:
        verbose_name_plural = 'Activities'
    date = models.DateField(verbose_name='Data')
    start_time = models.TimeField(verbose_name='Czas rozpoczęcia')
    end_time = models.TimeField(verbose_name='Czas zakończenia')
    baby = models.ForeignKey(
        Baby, on_delete=models.CASCADE, verbose_name='Dziecko', null=True, default=None, blank=False

In i get all the activities from database and send it to activity_list.html page

def activity_list(request):
    activity_list = Activity.objects.all().order_by('-date', '-start_time')
    title='Lista aktywności'
    return render(request, 'babybook/activity_list.html', locals())

There I can display all the data, but I would like to replace baby_id with the child’s first and last name.
In views, I have a method that changes my id to my first and last name

def getBabyName(id):
    baby_name = Baby.objects.get(id=id)
    return baby_name

But I don’t know how to pass the baby_name returned by the method instead of baby_id (or apart from baby_id) to the html page.

First, for clarity, this does not return the name of the baby. This function returns an instance of the model Baby.

Now, if you have an instance of Activity, you can directly access the related field using the standard Python attribute notation.
e.g. If an_activity is an instance of Activity, then the instance of Baby related to an_activity is

You’re right, it an object so i can access to it easily :slight_smile:
Thank You