5👍
✅
All you need to do is add a case to both the male and female metrics. Here’s an example, and then you can do the same for female = 0:
from django.db.models import Case, When, IntegerField
class MyHelperGenderAdmin(admin.ModelAdmin):
...
metrics = {
...
'male': Count(Case(
When(gender = 1, then = 1),
output_field = IntegerField())),
...
}
Source:stackexchange.com