I'm making a blog-like platform which includes an event page. I have a model as below:
class Event(models.Model):
dtime_start = models.DateTimeField(null=False, blank=False)
dtime_end = models.DateTimeField(null=False, blank=False)
Assuming I have a view called event_main
which projects all events. However, I want to project currently active events at the top of page, highlighted. So what I need is:
- to get exact request
datetime
of client - to filter
Event
instances having the requestdatetime
betweendtime_start
anddtime_end
I thought of solutions including for
loops and put the results in the list, however I don't really want to put model instances to a list, since there are QuerySet
s. Is there a built-in way to do this in Django?
###############
# Environment #
###############
python 3.2.5
pypy 2.4.0
django 1.8.7