python - Filtering on month value doesn't return objects -
i have newsitem
object in datebase. want filter newsitem
objects based on year , month values. first of all, here model:
class newsitem(models.model): maintitle = models.charfield(max_length=500) publish_start = models.datetimefield()
when call object on shell, output is:
in[15]: nitem[0].publish_start out[15]: datetime.datetime(2015, 7, 27, 10, 57, 50, tzinfo=<utc>)
the problem is, when filter newsitem objects based on month, can't object. filtering on year works fine.
newsitem.objects.all().filter(publish_start__year=2015)
returns object but
newsitem.objects.all().filter(publish_start__month=7)
or
newsitem.objects.all().filter(publish_start__day=27)
doesn't returns object.
according django docs, if use use_tz = true, datetime objects converted current time zone. filtering on timezone aware objects requires time zone definitions in database.
Comments
Post a Comment