Thursday, 28 December 2023

django make commands and help input

 https://stackoverflow.com/questions/42000687/what-are-the-differences-between-data-and-validated-data


 help = "seeder test"


    def add_arguments(self, parser):

        parser.add_argument('--mode', type=str, help="Mode")


    def handle(self, *args, **options):

        self.stdout.write('test -> init')

        run_seed(self, options['mode'])

        self.stdout.write('test -> complete')


 docker-compose run app sh -c "python manage.py seed --help"

 

[+] Creating 2/0

 ✔ Network backend_default  Created                                                                                               0.0s

 ✔ Container backend-db-1   Created                                                                                               0.0s

[+] Running 1/1

 ✔ Container backend-db-1  Started                                                                                                0.2s

usage: manage.py seed [-h] [--mode MODE] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback]

                      [--no-color] [--force-color] [--skip-checks]


seed database for testing and development.


options:

  -h, --help            show this help message and exit

  --mode MODE           Mode

  --version             Show program's version number and exit.

  -v {0,1,2,3}, --verbosity {0,1,2,3}

                        Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output

  --settings SETTINGS   The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the

                        DJANGO_SETTINGS_MODULE environment variable will be used.

  --pythonpath PYTHONPATH

                        A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".

  --traceback           Raise on CommandError exceptions.

  --no-color            Don't colorize the command output.

  --force-color         Force colorization of the command output.

  --skip-checks         Skip system checks.


No comments:

Post a Comment