mirror of https://github.com/django/django.git
[2.2.x] Changed poll_id to poll_ids in examples of custom management commands.
Backport of fa422dd78b
from master
This commit is contained in:
parent
3d4e53bcb1
commit
da10b647f7
|
@ -49,10 +49,10 @@ look like this::
|
||||||
help = 'Closes the specified poll for voting'
|
help = 'Closes the specified poll for voting'
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
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):
|
def handle(self, *args, **options):
|
||||||
for poll_id in options['poll_id']:
|
for poll_id in options['poll_ids']:
|
||||||
try:
|
try:
|
||||||
poll = Poll.objects.get(pk=poll_id)
|
poll = Poll.objects.get(pk=poll_id)
|
||||||
except Poll.DoesNotExist:
|
except Poll.DoesNotExist:
|
||||||
|
@ -77,7 +77,7 @@ look like this::
|
||||||
self.stdout.write("Unterminated line", ending='')
|
self.stdout.write("Unterminated line", ending='')
|
||||||
|
|
||||||
The new custom command can be called using ``python manage.py closepoll
|
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``
|
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
|
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):
|
class Command(BaseCommand):
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
# Positional arguments
|
# Positional arguments
|
||||||
parser.add_argument('poll_id', nargs='+', type=int)
|
parser.add_argument('poll_ids', nargs='+', type=int)
|
||||||
|
|
||||||
# Named (optional) arguments
|
# Named (optional) arguments
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
Loading…
Reference in New Issue