def handle(self, *args, **options): flights = Flight.objects.all() for flight in flights: for days in range(0, 31): parse_flight_from_command_line( flight_id=flight.id, departure_date=datetime.date.today() + datetime.timedelta(days=days), monthly=1) # raise CommandError('There is no flight with number="%s"' % arg)
def handle(self, *args, **options): with open(settings.BASE_DIR+"log.txt", "a") as myfile: myfile.write('[%s]:[%s]\n' % (datetime.datetime.now(), 'Cron daily flight run')) flights = Flight.objects.all() for flight in flights: try: parse_flight_from_command_line( flight_id=flight.id, departure_date=datetime.date.today(), monthly=0) except Flight.DoesNotExist: raise CommandError('There is an error occurred with flight number="%s"' % flight.id)