diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py
index 8965a8c..e8a4b0d 100644
|
a
|
b
|
class FileInput(Input):
|
| 262 | 262 | def value_from_datadict(self, data, files, name): |
| 263 | 263 | "File widgets take data from FILES, not POST" |
| 264 | 264 | return files.get(name, None) |
| | 265 | |
| | 266 | def _has_changed(self, initial, data): |
| | 267 | if data is None: |
| | 268 | return False |
| | 269 | return True |
| 265 | 270 | |
| 266 | 271 | class Textarea(Widget): |
| 267 | 272 | def __init__(self, attrs=None): |
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
index 0e69602..476179c 100644
|
a
|
b
|
u'<input type="file" class="fun" name="email" />'
|
| 202 | 202 | >>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) |
| 203 | 203 | u'<input type="file" class="fun" name="email" />' |
| 204 | 204 | |
| | 205 | Test for the behavior of _has_changed for FileInput. The value of data will |
| | 206 | more than likely come from request.FILES. The value of initial data will |
| | 207 | likely be a filename stored in the database. Since its value is of no use to |
| | 208 | a FileInput it is ignored. |
| | 209 | |
| | 210 | >>> w = FileInput() |
| | 211 | |
| | 212 | # No file was uploaded and no initial data. |
| | 213 | >>> w._has_changed(None, '') |
| | 214 | False |
| | 215 | |
| | 216 | # TODO: need to think about this case some more. |
| | 217 | >>> w._has_changed({}, '') |
| | 218 | False |
| | 219 | |
| | 220 | # A file was uploaded and no initial data. |
| | 221 | >>> w._has_changed({'filename': 'resume.txt', 'content': 'My resume'}, '') |
| | 222 | True |
| | 223 | |
| | 224 | # A file was not uploaded, but there is initial data |
| | 225 | >>> w._has_changed(None, 'resume.txt') |
| | 226 | False |
| | 227 | |
| | 228 | # A file was uploaded and there is initial data (file identity is not dealt |
| | 229 | # with here) |
| | 230 | >>> w._has_changed({'filename': 'resume.txt', 'content': 'My resume'}, 'resume.txt') |
| | 231 | True |
| | 232 | |
| 205 | 233 | # Textarea Widget ############################################################# |
| 206 | 234 | |
| 207 | 235 | >>> w = Textarea() |