Ticket #6009: patch.diff
File patch.diff, 1.6 KB (added by , 17 years ago) |
---|
-
django/newforms/fields.py
444 444 elif not data and initial: 445 445 return initial 446 446 try: 447 f = UploadedFile(data['filename'] , data['content'])447 f = UploadedFile(data['filename'].decode('utf8'), data['content']) 448 448 except TypeError: 449 449 raise ValidationError(self.error_messages['invalid']) 450 450 except KeyError: -
tests/regressiontests/model_fields/tests.py
1 """ 1 #encoding=utf8 2 __test__ = {'API_TESTS': """ 2 3 >>> from django.db.models.fields import * 3 4 4 5 # DecimalField … … 15 16 Traceback (most recent call last): 16 17 ... 17 18 ValidationError: [u'This value must be a decimal number.'] 18 """ 19 20 """} 21 22 from django.db.models import Model 23 from django.db.models.fields import FileField 24 from django.newforms import Form 25 from django.newforms.fields import FileField as FormFileField 26 27 class FileForm(Form): 28 file = FormFileField() 29 30 class FileModel(Model): 31 file = FileField(upload_to='/') 32 33 __test__['API_TESTS'] += """ 34 >>> f = FileForm({}, {'file' : {'filename' : 'kø.jpg', 'content' : 'data'}}) 35 >>> f.is_valid() 36 True 37 >>> m = FileModel.objects.create(file=f.cleaned_data['file']) 38 39 """ 40 No newline at end of file