Ticket #8336: 8336-disable_admin_media_serving-8354.diff

File 8336-disable_admin_media_serving-8354.diff, 1.7 KB (added by jakub_vysoky, 16 years ago)

option for disabling admin media serving

  • django/core/management/commands/runserver.py

    diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
    index 12808bc..c5a0b96 100644
    a b class Command(BaseCommand):  
    99            help='Tells Django to NOT use the auto-reloader.'),
    1010        make_option('--adminmedia', dest='admin_media_path', default='',
    1111            help='Specifies the directory from which to serve admin media.'),
     12        make_option('--noadminmedia', action='store_true', dest='disable_admin_media', default=False,
     13            help='Do not serve admin media files directly.'),
    1214    )
    1315    help = "Starts a lightweight Web server for development."
    1416    args = '[optional port number, or ipaddr:port]'
    class Command(BaseCommand):  
    3840
    3941        use_reloader = options.get('use_reloader', True)
    4042        admin_media_path = options.get('admin_media_path', '')
     43        disable_admin_media = options.get('disable_admin_media', False)
    4144        shutdown_message = options.get('shutdown_message', '')
    4245        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
    4346
    class Command(BaseCommand):  
    5053            print "Quit the server with %s." % quit_command
    5154            try:
    5255                path = admin_media_path or django.__path__[0] + '/contrib/admin/media'
    53                 handler = AdminMediaHandler(WSGIHandler(), path)
     56                handler = disable_admin_media and WSGIHandler() or AdminMediaHandler(WSGIHandler(), path)
    5457                run(addr, int(port), handler)
    5558            except WSGIServerException, e:
    5659                # Use helpful error messages instead of ugly tracebacks.
Back to Top