def generate_sections(self):
        """Return dictionary of source section slugs, name, and counts."""
        sources = Dataset.objects.values(
            'source', 'source_slug'
        ).annotate(source_count=Count('source_slug'))

        return sorted([
            {
                'slug': source['source_slug'],
                'name': source['source'],
                'count': source['source_count']
            }
            for source in sources
        ], key=lambda k: k['count'], reverse=True)
def generate_sections ( self ) : sources = Dataset . objects . values ( 'source' , 'source_slug' ) . annotate ( source_count = Count ( 'source_slug' ) ) return sorted ( [ { 'slug' : source [ 'source_slug' ] , 'name' : source [ 'source' ] , 'count' : source [ 'source_count' ] } for source in sources ] , key = lambda k : k [ 'count' ] , reverse = True )
Return dictionary of source section slugs, name, and counts.