Ticket #1099: admin_media_prefix_allow_absolute_paths.diff

File admin_media_prefix_allow_absolute_paths.diff, 842 bytes (added by Tom Tobin <korpios@…>, 18 years ago)

My take on the fix for this issue; supports http(s): and uses urljoin.

  • django/contrib/admin/templatetags/admin_modify.py

     
    1818    return '_'.join([s.lower() for s in word_re.findall(name)[:-1]])
    1919
    2020def include_admin_script(script_path):
    21     return '<script type="text/javascript" src="%s%s"></script>' % (settings.ADMIN_MEDIA_PREFIX, script_path)
     21    from urlparse import urljoin
     22    if not re.search(r'^(?:https?://|/)', script_path):
     23        script_path = urljoin(settings.ADMIN_MEDIA_PREFIX, script_path)
     24    return '<script type="text/javascript" src="%s"></script>' % script_path
    2225include_admin_script = register.simple_tag(include_admin_script)
    2326
    2427def submit_row(context):
Back to Top