Ticket #6009: patch.diff

File patch.diff, 1.6 KB (added by Casper Jensen, 17 years ago)
  • django/newforms/fields.py

     
    444444        elif not data and initial:
    445445            return initial
    446446        try:
    447             f = UploadedFile(data['filename'], data['content'])
     447            f = UploadedFile(data['filename'].decode('utf8'), data['content'])
    448448        except TypeError:
    449449            raise ValidationError(self.error_messages['invalid'])
    450450        except KeyError:
  • tests/regressiontests/model_fields/tests.py

     
    1 """
     1#encoding=utf8
     2__test__ = {'API_TESTS': """
    23>>> from django.db.models.fields import *
    34
    45# DecimalField
     
    1516Traceback (most recent call last):
    1617...
    1718ValidationError: [u'This value must be a decimal number.']
    18 """
     19
     20"""}
     21
     22from django.db.models import Model
     23from django.db.models.fields import FileField
     24from django.newforms import Form
     25from django.newforms.fields import FileField as FormFileField
     26
     27class FileForm(Form):
     28    file = FormFileField()
     29
     30class 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()
     36True
     37>>> m = FileModel.objects.create(file=f.cleaned_data['file'])
     38
     39"""
     40 No newline at end of file
Back to Top