if value and hasattr(value, 'url'):
    template = self.template_with_initial
substitutions['initial'] = '<a href="%s">%s</a>' % (escape(value.url),
    escape(force_unicode(os.path.basename(value.url))))
if not self.is_required:
    checkbox_name = self.clear_checkbox_name(name)
checkbox_id = self.clear_checkbox_id(checkbox_name)
substitutions['clear_checkbox_name'] = conditional_escape(checkbox_name)
substitutions['clear_checkbox_id'] = conditional_escape(checkbox_id)
substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs
    ={'id': checkbox_id})
substitutions['clear_template'] = self.template_with_clear % substitutions
return mark_safe(template % substitutions)
Django : customizing FileField value while editing a model