from auto_email.views import sendmail from .models import * from django.db.models import F def run_func_every_mid_night(): print("days decrease function") all_jp=JuggernautPackage.objects.all() for i in all_jp: if i.validity_days == 0: continue else: i.validity_days -= 1 i.save() print("days decrease by 1 from each package")