March 2020
Intermediate to advanced
608 pages
17h 17m
English
Django management commands are scripts with Command classes deriving from BaseCommand and overwriting the add_arguments() and handle() methods. The help attribute defines the help text for the management command. It can be seen when you type the following in the command line:
(env)$ python manage.py help import_music_from_csv
Django management commands use the built-in argparse module to parse the passed arguments. The add_arguments() method defines what positional or named arguments should be passed to the management command. In our case, we will add a positional file_path argument of the Unicode type. By having the nargs variable set to the 1 attribute, we allow only one value.
Read now
Unlock full access