I've made a custom command in django to delete a set account in CMD, but I want to be able to run the python file and have the command line ask me for the account number to delete then have it delete. This is what I have so far.
from django.core.management.base import BaseCommand, CommandError
from accounts.models import client
class Command(BaseCommand):
args = '<client_id client_id ...>'
help = 'Closes the specified account.'
def handle(self, *args, **options):
for client_id in args:
try:
x = client.objects.get(pk=int(client_id))
except client.DoesNotExist:
raise CommandError('Client "%s" does no exist' % client_id)
x.delete()
self.stdout.write('Successfully closed account "%s"' % client_id)