I want to add --env=prod/beta/alpha/dev to runserver so i can do python manage.py runserver --env=prod for example.
I've tried to add to settings.py:
parser = CommandParser(None)
parser.add_argument('--env')
parser.add_argument('args', nargs='*') # catch-all
try:
options, args = parser.parse_known_args(sys.argv[2:])
except CommandError:
pass # Ignore any option errors at this point.
APP_ENV = options.env or 'dev'
But I got:
usage: manage.py runserver [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color] [--ipv6] [--nothreading]
[--noreload] [--nostatic] [--insecure]
[addrport]
manage.py runserver: error: unrecognized arguments: --env=beta
Any idea how can I monkey patch runserver?
runserveris not suitable for production deployment.