FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit c3c9bb99 authored by Mike Knee's avatar Mike Knee
Browse files

feat: add management command to delete accounts

This is needed to support development and staging activities, so that we
can remove and re-populate test data for use in user acceptance testing.
parent c46aca2a
No related branches found
No related tags found
1 merge request!47Add management command to delete accounts
Pipeline #640285 passed
from pprint import pprint
from django.core.management.base import BaseCommand
from activate_account.models import Account
class Command(BaseCommand):
help = "Deletes account data in databases"
def handle(self, *args, **options):
account_count = Account.objects.all().count()
if account_count == 0:
self.stdout.write(self.style.SUCCESS("No accounts to delete."))
return
self.stdout.write(self.style.WARNING("Deleting account data in database..."))
self.stdout.write(f"There are currently {account_count} accounts in the database.")
self.stdout.write(self.style.WARNING("Are you sure you want to continue?"))
result = input("Enter 'yes' to delete all data: ")
if result.lower() == "yes":
pprint(Account.objects.all().delete())
else:
self.stdout.write("Not deleting any objects.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment