views:

133

answers:

1

how ill, get my register based in the current (actual) month in my queryset?, i have a ModelManager(), that just show the LIVE register status, but now i want to show the register with LIVE status and in the current (actual) month, i know that ill make something like .filter(...), but i dont know how get the current month..

model.py

#manager
class LiveNoticiaManager(models.Manager):
    def get_query_set(self):
        return super(LiveNoticiaManager,self).get_query_set().filter(status=self.model.LIVE_STATUS)

thanks guys.

+2  A: 

http://docs.djangoproject.com/en/dev/ref/models/querysets/#month

You can

>>> import datetime
>>> MyModel.objects.filter(mydatefield__year=datetime.date.today().year)\
           .filter(mydatefield__month=datetime.date.today().month)
skyl
thanks :) sos-skyl
Asinox
That should be rewritten as MyModel.objects.filter(... the model itself doesn't have a filter method.
Andre Miller
indeed, Andre, fixed.
skyl