Ticket #7000: open_browser.1.diff
File open_browser.1.diff, 4.1 KB (added by , 17 years ago) |
---|
-
django/core/management/commands/runserver.py
7 7 option_list = BaseCommand.option_list + ( 8 8 make_option('--noreload', action='store_false', dest='use_reloader', default=True, 9 9 help='Tells Django to NOT use the auto-reloader.'), 10 make_option('--browser', action='store_true', dest='open_browser', 11 help='Tells Django to open a browser.'), 10 12 make_option('--adminmedia', dest='admin_media_path', default='', 11 13 help='Specifies the directory from which to serve admin media.'), 12 14 ) … … 37 39 raise CommandError("%r is not a valid port number." % port) 38 40 39 41 use_reloader = options.get('use_reloader', True) 42 open_browser = options.get('open_browser', False) 40 43 admin_media_path = options.get('admin_media_path', '') 41 44 shutdown_message = options.get('shutdown_message', '') 42 45 quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' … … 51 54 try: 52 55 path = admin_media_path or django.__path__[0] + '/contrib/admin/media' 53 56 handler = AdminMediaHandler(WSGIHandler(), path) 57 if open_browser: 58 import webbrowser 59 url = "http://%s:%d/" % (addr, port) 60 webbrowser.open(url) 54 61 run(addr, int(port), handler) 55 62 except WSGIServerException, e: 56 63 # Use helpful error messages instead of ugly tracebacks. … … 70 77 if shutdown_message: 71 78 print shutdown_message 72 79 sys.exit(0) 73 if use_reloader :80 if use_reloader and not open_browser: 74 81 from django.utils import autoreload 75 82 autoreload.main(inner_run) 76 83 else: -
extras/django_bash_completion
42 42 prev="${COMP_WORDS[COMP_CWORD-1]}" 43 43 44 44 # Standalone options 45 opts="--help --settings --pythonpath --noinput --noreload -- format --indent --verbosity --adminmedia --version"45 opts="--help --settings --pythonpath --noinput --noreload --browser --format --indent --verbosity --adminmedia --version" 46 46 # Actions 47 47 actions="adminindex createcachetable dbshell diffsettings \ 48 48 dumpdata flush inspectdb loaddata reset runfcgi runserver \ -
docs/man/django-admin.1
53 53 .B runfcgi help 54 54 for help on the KEY=val pairs. 55 55 .TP 56 .BI "runserver [" "\-\-noreload" "] [" "\-\- adminmedia=ADMIN_MEDIA_PATH" "] [" "port|ipaddr:port" "]"56 .BI "runserver [" "\-\-noreload" "] [" "\-\-browser" "] [" "\-\-adminmedia=ADMIN_MEDIA_PATH" "] [" "port|ipaddr:port" "]" 57 57 Starts a lightweight Web server for development. 58 58 .TP 59 59 .BI "shell [" "\-\-plain" "]" … … 136 136 .TP 137 137 .I \-\-adminmedia=ADMIN_MEDIA_PATH 138 138 Specifies the directory from which to serve admin media when using the development server. 139 .TP 140 .I \-\-browser 141 Open the URL of the development server in the default web browser. 139 142 140 143 .SH "ENVIRONMENT" 141 144 .TP -
docs/django-admin.txt
389 389 390 390 django-admin.py runserver --adminmedia=/tmp/new-admin-style/ 391 391 392 --browser 393 ~~~~~~~~~ 394 395 Use the ``--browser`` option to tell Django to open the URL of the development 396 server automatically with the system web browser. As soon as you start it with 397 this option the use of the auto-reloader is disabled to prevent a recurring 398 opening in the browser. 399 400 Example usage:: 401 402 django-admin.py runserver --browser 403 392 404 --noreload 393 405 ~~~~~~~~~~ 394 406