1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

Fixed #25680 -- Added django-admin shell --command option.

Add a -c option to the shell command to execute a command passed as a
string as Django.
This commit is contained in:
Niels Van Och
2015-11-07 12:07:28 +01:00
committed by Tim Graham
parent 0cc32a8f97
commit 7f7553dd30
5 changed files with 38 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ class Command(BaseCommand):
help='When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.')
parser.add_argument('-i', '--interface', choices=self.shells, dest='interface',
help='Specify an interactive interpreter interface. Available options: "ipython", "bpython", and "python"')
parser.add_argument('-c', '--command', dest='command',
help='Instead of opening an interactive shell, run a command as Django and exit.')
def _ipython_pre_011(self):
"""Start IPython pre-0.11"""
@@ -93,6 +95,11 @@ class Command(BaseCommand):
)
options['interface'] = 'python'
# Execute the command and exit.
if options['command']:
exec(options['command'])
return
available_shells = [options['interface']] if options['interface'] else self.shells
for shell in available_shells: