from collections import Counter
import datetime


from parler.managers import TranslatableManager


class RelatedManager(TranslatableManager):

    # TODO: uncomment this when we'll have image field
    # def get_query_set(self):
    #     qs = super(RelatedManager, self).get_query_set()
    #     return qs.select_related('image_fk')

    def get_months(self, namespace):
        """
        Get months with posts count for given namespace string.

        This means how much posts there are in each month. Results are ordered
        by date.
        """
        # done in a naive way as Django is having tough time while aggregating
        # on date fields
        entries = self.filter(namespace__namespace=namespace)
        dates = entries.values_list('publishing_date', flat=True)
        dates = [(x.year, x.month) for x in dates]
        date_counter = Counter(dates)
        dates = set(dates)
        dates = sorted(dates, reverse=True)
        months = [
            # Use day=3 to make sure timezone won't affect this hacks'
            # month value. There are UTC+14 and UTC-12 timezones.
            {'date': datetime.date(year=year, month=month, day=3),
             'count': date_counter[year, month]}
            for year, month in dates]
        return months

@@ -1,12 +1,21 @@
+try:%0A    
 from collect
@@ -34,16 +34,82 @@
 Counter%0A
+except ImportError:%0A    from backport_collections import Counter%0A%0A
 import d
@@ -117,17 +117,16 @@
 tetime%0A%0A
-%0A
 from par

Add fallback: from backport_collections import Counter