Source code for users.management.commands.delete_expired_accounts
# Usage:
# python manage.py delete_expired_accounts # delete accounts past the grace period
from django.core.management.base import BaseCommand
from users.models import User
[docs]
class Command(BaseCommand):
help = "Delete user accounts that are past the grace period"
[docs]
def handle(self, *args, **options):
deleted = User.permanently_delete_expired_accounts()
account_word = "expired account" if deleted == 1 else "expired accounts"
self.stdout.write(f"Deleted {deleted} {account_word}.")