Got an problem that I am struggling to solve..

I have:

class Address(models.Model):
name = models.CharField()
event_date = models.DateTime()


event1, 25/01/2015
event2, 27/01/2015
event3, 05/02/2015

and so on…

what I am trying to figure out is, how to calculate the days between each 
event.

so event2, would be 2 days, event3 would be 9 days etc.

want to end up with something like this that is passed to the template
event1, 25/01/2015
event2, 27/01/2015, 2
event3, 05/02/2015, 9


its the mechanics I am having trouble working out, my initial though was to 
have a def on the model that accepted a datetime object. Somehow in a loop 
i would get the diatomite from the next event and pass it in and calc days 
on self.event_date… cant think how to do it.

has anyone else needed something like this? or am I thinking about it 
wrong..

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63b0691e-34b1-4634-bf29-640583f22bae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to