class event_archive(models.Model):
event_id = models.AutoField(primary_key=True)
date_submitted = models.DateTimeField()
event_start_time = models.DateTimeField()
event_end_time = models.DateTimeField()
event_closed = models.BooleanField()
I want to do this : Here is the pseudo_code:
event = event_archive.objects.all()
for e in event:
if event_start_time > datetime_now()
print "upcoming";
elif event_start_time < datetime_now() < event_end_time
print "now";
elif event_end_time < datetime_now() < **24 hours passed the event ends**
print "%d hours ago",%hour;
elif event_end_time < datetime_now() > **24 hours passed the event ends** and event_end_time < datetime_now() < **48 hours passed the event ends**
print "yesterday";
else
print "recorded"
endif;
endfor;
** I am very new in programming and python..Please dont mind if I asked very silly question or does not put the question clearly..In the bold line I am not sure what should I use??
I need help to write my django view function..Any help please..
If you are doing this for a template, use the
timeuntilandtimesincefilters which are designed for this task.