### Eclipse Workspace Patch 1.0
#P django-trunk
Index: django/forms/widgets.py
===================================================================
--- django/forms/widgets.py	(revision 15840)
+++ django/forms/widgets.py	(working copy)
@@ -316,6 +316,10 @@
         Given the name of the clear checkbox input, return the HTML id for it.
         """
         return name + '_id'
+    
+    def get_initial_value(self, value):
+        return u'<a href="%s">%s</a>'  % (escape(value.url),
+                                          escape(force_unicode(value)))
 
     def render(self, name, value, attrs=None):
         substitutions = {
@@ -329,9 +333,7 @@
 
         if value and hasattr(value, "url"):
             template = self.template_with_initial
-            substitutions['initial'] = (u'<a href="%s">%s</a>'
-                                        % (escape(value.url),
-                                           escape(force_unicode(value))))
+            substitutions['initial'] = self.get_initial_value(value)
             if not self.is_required:
                 checkbox_name = self.clear_checkbox_name(name)
                 checkbox_id = self.clear_checkbox_id(checkbox_name)
Index: tests/regressiontests/forms/tests/widgets.py
===================================================================
--- tests/regressiontests/forms/tests/widgets.py	(revision 15702)
+++ tests/regressiontests/forms/tests/widgets.py	(working copy)
@@ -9,12 +9,12 @@
 from django.forms.widgets import RadioFieldRenderer
 from django.utils import copycompat as copy
 from django.utils import formats
+from django.utils.html import escape
 from django.utils.safestring import mark_safe
 from django.utils.translation import activate, deactivate
 from django.utils.unittest import TestCase
 
 
-
 class FormsWidgetTestCase(TestCase):
     # Each Widget class corresponds to an HTML form widget. A Widget knows how to
     # render itself, given a field name and some data. Widgets don't perform
@@ -1107,7 +1107,7 @@
         self.assertTrue(u'something&lt;div onclick=&quot;alert(&#39;oops&#39;)&quot;&gt;.jpg' in output)
         self.assertTrue(u'my&lt;div&gt;file' in output)
         self.assertFalse(u'my<div>file' in output)
-
+        
     def test_clear_input_renders_only_if_not_required(self):
         """
         A ClearableFileInput with is_required=False does not render a clear
@@ -1130,6 +1130,20 @@
         self.assertEqual(widget.render('myfile', None),
                          u'<input type="file" name="myfile" />')
 
+    def test_initial_value(self):
+        widget = ClearableFileInput()
+        widget.is_required = True
+        self.assertEqual(widget.get_initial_value(FakeFieldFile()), u'<a href="something">something</a>')
+
+    def test_initial_value_override(self):
+        class ThumbnailClearableFileInput(ClearableFileInput):
+            def get_initial_value(self, value):
+                return u'<img src="%s" >'  % (escape(value.url))
+        widget = ThumbnailClearableFileInput()
+        widget.is_required = True
+        self.assertEqual(widget.render('myfile', FakeFieldFile()),
+                         u'Currently: <img src="something" > <br />Change: <input type="file" name="myfile" />')
+
     def test_clear_input_checked_returns_false(self):
         """
         ClearableFileInput.value_from_datadict returns False if the clear
