Ticket #2600: admin_media_path.diff

File admin_media_path.diff, 3.2 KB (added by adurdin@…, 18 years ago)

patch that adds --adminmediapath setting to manage.py

  • django/core/servers/basehttp.py

     
    594594    Use this ONLY LOCALLY, for development! This hasn't been tested for
    595595    security and is not super efficient.
    596596    """
    597     def __init__(self, application):
     597    def __init__(self, application, media_dir):
    598598        from django.conf import settings
    599         import django
    600599        self.application = application
    601         self.media_dir = django.__path__[0] + '/contrib/admin/media'
     600        self.media_dir = media_dir
    602601        self.media_url = settings.ADMIN_MEDIA_PREFIX
    603602
    604603    def __call__(self, environ, start_response):
  • django/core/management.py

     
    10351035        sys.stderr.write(s.read())
    10361036        sys.exit(1)
    10371037
    1038 def runserver(addr, port, use_reloader=True):
     1038def runserver(addr, port, use_reloader=True, admin_media_dir=''):
    10391039    "Starts a lightweight Web server for development."
    10401040    from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
    10411041    from django.core.handlers.wsgi import WSGIHandler
     
    10531053        print "Development server is running at http://%s:%s/" % (addr, port)
    10541054        print "Quit the server with %s." % quit_command
    10551055        try:
    1056             run(addr, int(port), AdminMediaHandler(WSGIHandler()))
     1056            import django
     1057            path = admin_media_dir or django.__path__[0] + '/contrib/admin/media'
     1058            handler = AdminMediaHandler(WSGIHandler(), path)
     1059            run(addr, int(port), handler)
    10571060        except WSGIServerException, e:
    10581061            # Use helpful error messages instead of ugly tracebacks.
    10591062            ERRORS = {
     
    10741077        autoreload.main(inner_run)
    10751078    else:
    10761079        inner_run()
    1077 runserver.args = '[--noreload] [optional port number, or ipaddr:port]'
     1080runserver.args = '[--noreload] [--adminmediapath=ADMIN_MEDIA_PATH] [optional port number, or ipaddr:port]'
    10781081
    10791082def createcachetable(tablename):
    10801083    "Creates the table needed to use the SQL cache backend"
     
    12251228        help='Tells Django to use plain Python, not IPython, for "shell" command.')
    12261229    parser.add_option('--noreload', action='store_false', dest='use_reloader', default=True,
    12271230        help='Tells Django to NOT use the auto-reloader when running the development server.')
     1231    parser.add_option('--adminmediapath', dest='admin_media_path', default='',
     1232        help='Allows admin media to be served from a directory other than [django-path]/contrib/admin/media')
    12281233    options, args = parser.parse_args(argv[1:])
    12291234
    12301235    # Take care of options.
     
    12801285                addr, port = args[1].split(':')
    12811286            except ValueError:
    12821287                addr, port = '', args[1]
    1283         action_mapping[action](addr, port, options.use_reloader)
     1288        action_mapping[action](addr, port, options.use_reloader, options.admin_media_path)
    12841289    elif action == 'runfcgi':
    12851290        action_mapping[action](args[1:])
    12861291    else:
Back to Top