Django template tag format

William

I have the following method on a model:

@property
def get_total_planned_stops(self, *args, **kwargs):
    owner = self.owner
    planned_total = DailyRoute.objects.filter(stage=1).aggregate(Sum('planned_stops'))
    return planned_total

In my template the variable {{ item.get_total_planned_stops}} renders as:

{'planned_stops__sum': 183}

I only want the number to be displayed. What am I doing wrong?

Arpit Solanki

aggregate function returns a dict format data that's why you are seeing a dict in the output.

Try to access the key value.

 {{ item.get_total_planned_stops.planned_stops__sum }}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related