Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. >class Event(models.Model):
  2. >somefield
  3. >somefield
  4. >reminder=models.IntegerField('Reminder', default=0, choices=REMINDER_STATUS)
  5. >reminderx = models.IntegerField('Days',blank=True, null=True)
  6.  
  7. today = date.today()
  8. a = Event.objects.filter(del_f=0)
  9. is_today = []
  10. is_week=[]
  11. is_custom =[]
  12.  
  13. for i in a:
  14. print('i:',i)
  15. reminder = i.reminder
  16.  
  17. if reminder == 1 :
  18. rtoday = i.start_date.date() - timedelta(days=1)
  19. print('rtoday:',rtoday)
  20. if rtoday == today:
  21. is_today.append(i)
  22. if reminder == 2 :
  23. rweek = i.start_date.date() - timedelta(days=7)
  24. if rweek == today:
  25. is_week.append(i)
  26.  
  27. if reminder == 3 :
  28. reminderx = i.reminderx
  29. rcustom = i.start_date.date() - datetime.timedelta(days= reminderx)
  30. if rcustom == today:
  31. is_custom.append(i)
  32.  
  33. context['today'] = is_today
  34. context['week'] = is_week
  35. context['custom'] = is_custom
  36.  
  37. return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement