Ticket #2600: admin_media_path.diff
File admin_media_path.diff, 3.2 KB (added by , 18 years ago) |
---|
-
django/core/servers/basehttp.py
594 594 Use this ONLY LOCALLY, for development! This hasn't been tested for 595 595 security and is not super efficient. 596 596 """ 597 def __init__(self, application ):597 def __init__(self, application, media_dir): 598 598 from django.conf import settings 599 import django600 599 self.application = application 601 self.media_dir = django.__path__[0] + '/contrib/admin/media'600 self.media_dir = media_dir 602 601 self.media_url = settings.ADMIN_MEDIA_PREFIX 603 602 604 603 def __call__(self, environ, start_response): -
django/core/management.py
1035 1035 sys.stderr.write(s.read()) 1036 1036 sys.exit(1) 1037 1037 1038 def runserver(addr, port, use_reloader=True ):1038 def runserver(addr, port, use_reloader=True, admin_media_dir=''): 1039 1039 "Starts a lightweight Web server for development." 1040 1040 from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException 1041 1041 from django.core.handlers.wsgi import WSGIHandler … … 1053 1053 print "Development server is running at http://%s:%s/" % (addr, port) 1054 1054 print "Quit the server with %s." % quit_command 1055 1055 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) 1057 1060 except WSGIServerException, e: 1058 1061 # Use helpful error messages instead of ugly tracebacks. 1059 1062 ERRORS = { … … 1074 1077 autoreload.main(inner_run) 1075 1078 else: 1076 1079 inner_run() 1077 runserver.args = '[--noreload] [ optional port number, or ipaddr:port]'1080 runserver.args = '[--noreload] [--adminmediapath=ADMIN_MEDIA_PATH] [optional port number, or ipaddr:port]' 1078 1081 1079 1082 def createcachetable(tablename): 1080 1083 "Creates the table needed to use the SQL cache backend" … … 1225 1228 help='Tells Django to use plain Python, not IPython, for "shell" command.') 1226 1229 parser.add_option('--noreload', action='store_false', dest='use_reloader', default=True, 1227 1230 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') 1228 1233 options, args = parser.parse_args(argv[1:]) 1229 1234 1230 1235 # Take care of options. … … 1280 1285 addr, port = args[1].split(':') 1281 1286 except ValueError: 1282 1287 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) 1284 1289 elif action == 'runfcgi': 1285 1290 action_mapping[action](args[1:]) 1286 1291 else: