sum(list(map(lambda item3: len(item3), list(filter(lambda item2: item2[0].hoge == 3, list(
map(lambda item: list(item.huga.all()), list(piyo.all())))))
)))
** Doyadoya ** lambda expressions combined with Django queries.
I will die after a month, so I will stop
#Data acquisition
piyo_list = list(piyo.all())
#Get detailed data
huga_list = list(map(lambda item:list(item.huga.all()), piyo_list))
#Level 1,Get 2
hoge_list = list(filter(lambda item: item[0].level == 1 or item[0].level == 2,huga_list))
#Level 1,Get the number of 2
level_list = list(map(lambda item: len(item), hoge_list))
#Get the total number of levels
sum_level = sum(level_list)
I know I want to do it, but I will stop.
Recommended Posts