diff options
| author | mentix02 <manan.yadav02@gmail.com> | 2019-05-10 18:01:49 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-05-20 10:11:38 +0200 |
| commit | fa422dd78b9a90143913ebb1d8c0e796504c2bee (patch) | |
| tree | 196d91a029b855e481ce9614b15b5fbd0de123ae /docs | |
| parent | c38e7a79f4354ee831f92deb7a658fc0387e3bec (diff) | |
Changed poll_id to poll_ids in examples of custom management commands.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/howto/custom-management-commands.txt | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt index aeee00016a..79ad61675d 100644 --- a/docs/howto/custom-management-commands.txt +++ b/docs/howto/custom-management-commands.txt @@ -49,10 +49,10 @@ look like this:: help = 'Closes the specified poll for voting' def add_arguments(self, parser): - parser.add_argument('poll_id', nargs='+', type=int) + parser.add_argument('poll_ids', nargs='+', type=int) def handle(self, *args, **options): - for poll_id in options['poll_id']: + for poll_id in options['poll_ids']: try: poll = Poll.objects.get(pk=poll_id) except Poll.DoesNotExist: @@ -77,7 +77,7 @@ look like this:: self.stdout.write("Unterminated line", ending='') The new custom command can be called using ``python manage.py closepoll -<poll_id>``. +<poll_ids>``. The ``handle()`` method takes one or more ``poll_ids`` and sets ``poll.opened`` to ``False`` for each one. If the user referenced any nonexistent polls, a @@ -97,7 +97,7 @@ options can be added in the :meth:`~BaseCommand.add_arguments` method like this: class Command(BaseCommand): def add_arguments(self, parser): # Positional arguments - parser.add_argument('poll_id', nargs='+', type=int) + parser.add_argument('poll_ids', nargs='+', type=int) # Named (optional) arguments parser.add_argument( |
