Django aggregate and grouping : code cleanliness challenge ...
Here is a small challenge that I would like to submit to you.

My goal here is to see if some code I have developed really make life simpler for aggregating and grouping, or if I have just missed something big ...
 _______________
*PROBLEM*

Here are 3 very simple models :

    >>> class Instrument(models.Model):
    ...     name = models.CharField(max_length=100)
    ... 
    >>> class Musician(models.Model):
    ...     instrument = models.ForeignKey(Instrument)
    ... 
    >>> class Song(models.Model):
    ...     author = models.ForeignKey(Musician)

Please, write a clean, concise, reusable code (I mean something that you can easily re-use to group by different attributes), that _counts the number of songs, grouped by instrument name and by author_
________________
Thank you for your help !!!
Django aggregate and grouping : code cleanliness challenge ...
===

Here is a small challenge that I would like to submit to you.

My goal here is to see if some code I have developed really make life simpler for aggregating and grouping, or if I have just missed something big ...
 _______________
*PROBLEM*

Here are 3 very simple models :

    >>> class Instrument(models.Model):
    ...     name = models.CharField(max_length=100)
    ... 
    >>> class Musician(models.Model):
    ...     instrument = models.ForeignKey(Instrument)
    ... 
    >>> class Song(models.Model):
    ...     author = models.ForeignKey(Musician)

Please, write a clean, concise, reusable code (I mean something that you can easily re-use to group by different attributes), that _counts the number of songs, grouped by instrument name and by author_
________________
Thank you for your help !!!