Skip to content

Instantly share code, notes, and snippets.

@drager
Created February 14, 2015 17:38
Show Gist options
  • Save drager/3fd7e612dbded567a92e to your computer and use it in GitHub Desktop.
Save drager/3fd7e612dbded567a92e to your computer and use it in GitHub Desktop.
from django.contrib.auth.models import User
from django.core.management.base import NoArgsCommand
from django.utils.timezone import now
class Command(NoArgsCommand):
help = "Delete inactive users that has a expired activation key."
def handle(self, **options):
User.objects.filter(is_active=False, userprofile__key_expires__lte=now()).delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment