FileInput with download like (like the fileinput on admin)

1
2
3
4
5
6
7
8
class MyFileInput(forms.FileInput):
    def render(self,name, value, attrs=None):
        output = []
        if value and hasattr(value, "url"):
            output.append('%s <a target="_blank" href="%s">%s</a> <br />%s ' % \
                (_('Actual:'), value.url, value, _('Cambio:')))
        output.append(super(MyFileInput, self).render(name, value, attrs))
        return mark_safe(u''.join(output))

More like this

  1. Add buttons in admin forms by mamat 5 years, 7 months ago
  2. django-admin custom filter: IS NULL/IS NOT NULL by Eloff 4 years, 1 month ago
  3. instant 'master' admin site by dschein2 6 years, 9 months ago
  4. showing environment variables in the django admin by tonemcd 4 years, 3 months ago
  5. Serve admin-media from urls.py by wolever 2 years, 7 months ago

Comments

darek (on March 15, 2011):

Django 1.3 has already this feature.

#

(Forgotten your password?)