1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
from django.utils import timezone from web.models import Event def deactivate(): today = timezone.now() active_events = Event.objects.filter(active=True).all() for event in active_events: if 'BP' in event.name: if event.end_date < today: event.active = False event.save()