Add confirmation step to custom Django management/manage.py command
<p>I created the following custom management command following <a href="https://docs.djangoproject.com/en/1.10/howto/custom-management-commands/" rel="noreferrer">this tutorial</a>.</p>

<pre><code>from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User

from topspots.models import Notification


class Command(BaseCommand):
    help = 'Sends message to all users'

    def add_arguments(self, parser):
        parser.add_argument('message', nargs='?')

    def handle(self, *args, **options):
        message = options['message']
        users = User.objects.all()
        for user in users:
            Notification.objects.create(message=message, recipient=user)

        self.stdout.write(
            self.style.SUCCESS(
                'Message:\n\n%s\n\nsent to %d users' % (message, len(users))
            )
        )
</code></pre>

<p>It works exactly as I want it to, but I would like to add a confirmation step so that before the <code>for user in users:</code> loop you are asked if you really want to send message X to N users, and the command is aborted if you choose "no". </p>

<p>I assume this can be easily done because it happens with some of the built-in management commands, but it doesn't seem to cover this in the tutorial and even after some searching and looking at the source for the built-in management commands, I have not been able to figure it out on my own.</p>