temporary update
This commit is contained in:
16
rog/management/commands/cleanup_temp_users.py
Normal file
16
rog/management/commands/cleanup_temp_users.py
Normal file
@ -0,0 +1,16 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
from rog.models import TempUser # アプリ名 'rog' を適切に変更してください
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Deletes expired temporary user records'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
expired_users = TempUser.objects.filter(expires_at__lt=timezone.now())
|
||||
count = expired_users.count()
|
||||
expired_users.delete()
|
||||
self.stdout.write(self.style.SUCCESS(f'Successfully deleted {count} expired temporary user records'))
|
||||
|
||||
|
||||
# cron job の設定
|
||||
# 0 3 * * * /path/to/your/python /path/to/your/manage.py cleanup_temp_users
|
||||
Reference in New Issue
Block a user