From 7b536046a9f3c7d684366055dd8ddc7d013e0820 Mon Sep 17 00:00:00 2001 From: Thomas Chamberlin Date: Fri, 9 Mar 2018 14:04:21 -0500 Subject: [PATCH] Updated management command's argument handling for Django 1.8\+ It appears that Django switched from optparse to argparse in Django 1.8. In Django 1.10 it appears that the compatibility mode for optparse-style managemnt commands was removed, and thus these were broken https://docs.djangoproject.com/en/1.11/internals/deprecation/#deprecation-removed-in-1-10 https://docs.djangoproject.com/en/1.11/releases/1.8/#extending-management-command-arguments-through-command-option-list https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/ --- .../management/commands/processincomingmessage.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/django_mailbox/management/commands/processincomingmessage.py b/django_mailbox/management/commands/processincomingmessage.py index c48e23b..42276d1 100644 --- a/django_mailbox/management/commands/processincomingmessage.py +++ b/django_mailbox/management/commands/processincomingmessage.py @@ -16,8 +16,13 @@ logging.basicConfig(level=logging.INFO) class Command(BaseCommand): - args = "<[Mailbox Name (optional)]>" - command = "Receive incoming mail via stdin" + help = "Receive incoming mail via stdin" + + def add_arguments(self, parser): + parser.add_argument( + 'mailbox_name', + help="The name of the mailbox that will receive the message" + ) def handle(self, mailbox_name=None, *args, **options): message = email.message_from_string(sys.stdin.read())