Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #76 -- development server now serves images, too, at whatever r…

…elative URL is provided by ADMIN_MEDIA_PREFIX

git-svn-id: http://code.djangoproject.com/svn/django/trunk@186 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 62cc287b2b6466e877b2f46d9e0825fb294f542e 1 parent a750697
Adrian Holovaty adrianholovaty authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 django/core/handlers/wsgi.py
11 django/core/handlers/wsgi.py
View
@@ -252,18 +252,21 @@ def __init__(self, application):
from django.conf import settings
import django
self.application = application
- self.media_dir = django.__path__[0] + '/conf/admin_templates'
+ self.media_dir = django.__path__[0] + '/conf/admin_media'
self.media_url = settings.ADMIN_MEDIA_PREFIX
def __call__(self, environ, start_response):
import os.path
- # Ignore requests that aren't under ADMIN_MEDIA_PREFIX.
- if not environ['PATH_INFO'].startswith(self.media_url):
+ # Ignore requests that aren't under ADMIN_MEDIA_PREFIX. Also ignore
+ # all requests if ADMIN_MEDIA_PREFIX isn't a relative URL.
+ if self.media_url.startswith('http://') or self.media_url.startswith('https://') \
+ or not environ['PATH_INFO'].startswith(self.media_url):
return self.application(environ, start_response)
# Find the admin file and serve it up, if it exists and is readable.
- file_path = os.path.join(self.media_dir, environ['PATH_INFO'][1:])
+ relative_url = environ['PATH_INFO'][len(self.media_url):]
+ file_path = os.path.join(self.media_dir, relative_url)
if not os.path.exists(file_path):
status = '404 NOT FOUND'
headers = {'Content-type': 'text/plain'}
Please sign in to comment.
Something went wrong with that request. Please try again.