Django Management Command Argument

Add this method to your Command class:

def add_arguments(self, parser):
    parser.add_argument('my_int_argument', type=int)

You can then use your option in the code, like this:

def handle(self, *args, **options):
    my_int_argument = options['my_int_argument']

The benefit of doing it this way is that the help output is automatically generated for manage.py my_command --help

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)