Hi, Not sure it's a good idea to do database query inside the template. Templates are capable of running some logics but for a heavy-lifting job like database query, it should be a good practice to do it in the view, and only pass the results to the template.
On Sun, Aug 9, 2020 at 4:30 AM Agoua David <[email protected]> wrote: > As Django template engine do not support the parenthèses you Can try to > make a custom filter > > Le sam. 8 août 2020 à 20:27, Agoua David <[email protected]> a écrit : > >> You Can try to use .count instead >> >> Le sam. 8 août 2020 à 17:56, N'BE SORO <[email protected]> a écrit : >> >>> Good evening please >>> >>> Can you help me? >>> >>> I want to display the number of items with a filter. >>> Example: >>> this call returns 4 elements >>> {{ item.class.classecours.all|length}} >>> >>> at the .all level >>> make an item.class.classecours.filter(status==True)|length >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CAOtSHp_wH9Xy-sf9t%2BMdtWB-bnRX680R9iJwZAnyZXh%3DxV%3De%3Dg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CAOtSHp_wH9Xy-sf9t%2BMdtWB-bnRX680R9iJwZAnyZXh%3DxV%3De%3Dg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAByCr6iR%2BKojR-csC3Rv5zqYd7mUG4%2B%2BnvEcM_ebZmM%2BceRmsw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAByCr6iR%2BKojR-csC3Rv5zqYd7mUG4%2B%2BnvEcM_ebZmM%2BceRmsw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGQ3pf-MmY%2BnNLEZHEyyPGE46%2Bv9s52Vvic2AfhdDGJ36Jwr4g%40mail.gmail.com.

