Skip to content

Commit

Permalink
[2.2.x] Changed poll_id to poll_ids in examples of custom management …
Browse files Browse the repository at this point in the history
…commands.

Backport of fa422dd from master
  • Loading branch information
mentix02 authored and felixxm committed May 20, 2019
1 parent 3d4e53b commit da10b64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/howto/custom-management-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit da10b64

Please sign in to comment.