#!/usr/bin/env python
# encoding: utf-8


from ..models import Post, Category
from django.db.models.aggregates import Count
from django import template

register = template.Library()

@register.simple_tag
def archives():
    return Post.objects.dates('created_time', 'month', order='DESC')

@register.simple_tag
def get_categories():
    return Category.objects.annotate(num_posts = Count('post'))
