'Get a queryset properly filtered according to `allow_future` and any
extra lookup kwargs.'

def get_dated_queryset(self, ordering=None, **lookup):

    qs = self.get_queryset().filter(**lookup)
    date_field = self.get_date_field()
    allow_future = self.get_allow_future()
    allow_empty = self.get_allow_empty()
    paginate_by = self.get_paginate_by(qs)
    if (ordering is not None):
        qs = qs.order_by(ordering)
    if (not allow_future):
        now = (timezone.now() if self.uses_datetime_field else timezone_today())
        qs = qs.filter(**{(u'%s__lte' % date_field): now})
    if (not allow_empty):
        is_empty = ((len(qs) == 0) if (paginate_by is None) else (not qs.exists()))
        if is_empty:
            raise Http404((_(u'No    %(verbose_name_plural)s    available') % {u'verbose_name_plural': force_text(qs.model._meta.verbose_name_plural)}))
    return qs
