Render a single ``FileUpload`` model instance using the
    appropriate rendering template and the given keyword options, and
    return the rendered HTML.
    
    The template used to render each upload is selected based on the
    mime-type of the upload. For an upload with mime-type
    "image/jpeg", assuming the default ``template_path`` of
    "adminfiles/render", the template used would be the first one
    found of the following: ``adminfiles/render/image/jpeg.html``,
    ``adminfiles/render/image/default.html``, and
    ``adminfiles/render/default.html``

def render_upload(upload, template_path="adminfiles/render/", **options):
    """
    Render a single ``FileUpload`` model instance using the
    appropriate rendering template and the given keyword options, and
    return the rendered HTML.
    
    The template used to render each upload is selected based on the
    mime-type of the upload. For an upload with mime-type
    "image/jpeg", assuming the default ``template_path`` of
    "adminfiles/render", the template used would be the first one
    found of the following: ``adminfiles/render/image/jpeg.html``,
    ``adminfiles/render/image/default.html``, and
    ``adminfiles/render/default.html``
    
    """
    if upload is None:
        return settings.ADMINFILES_STRING_IF_NOT_FOUND
    template_name = options.pop('as', None)
    if template_name:
        templates = [template_name,
                     "%s/default" % template_name.split('/')[0],
                     "default"]
    else:
        templates = [join(upload.content_type, upload.sub_type),
                     join(upload.content_type, "default"),
                     "default"]
    tpl = template.loader.select_template(
        ["%s.html" % join(template_path, p) for p in templates])
    return tpl.render(template.Context({'upload': upload,
                                        'options': options}))