Я хочу использовать py manage.py own_command.
Я получил следующий код:
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'create user'
def add_arguments(self, parser):
parser.add_argument('--username', type=str, help='set username')
parser.add_argument('--password', type=str, help='set password')
parser.add_argument('--email', type=str, help='set password')
parser.add_argument('--group', type=list, default=[], action='append', help='set group(s) like ["basic", "advanced"]')
parser.add_argument('--permission', type=list, default=[], action='append', help='set permission(s) like ["delete", "write"]')
>py manage.py create_app_user --username dustin --password hdf --email "" --group ["admin", "basic"
]
создает
usage: manage.py create_app_user [-h] [--username USERNAME]
[--password PASSWORD] [--email EMAIL]
[--group GROUP] [--permission PERMISSION]
[--version] [-v {0,1,2,3}]
[--settings SETTINGS]
[--pythonpath PYTHONPATH] [--traceback]
[--no-color]
manage.py create_app_user: error: unrecognized arguments: basic
]
Я нашел решения для django <= 1.7 НО не для> = 2.1