Skip to content
Advertisement

Tag: django-orm

Django group by Choice Field and COUNT Zeros

Consider the following django model: Now, I’d like to group all Ratings by the number of ratings per category like this: which returns a QuerySets like this: Is there a way to include all not-rated dimensions? To achieve an output like: Answer First we will create a dictionary with counts for all dimensions initialised to 0. Next we will query

Advertisement