diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
| commit | aa239e3e5405933af6a29dac3cf587b59a099927 (patch) | |
| tree | ea2cbd139c9a8cf84c09e0b2008bff70e05927ef /tests/regressiontests/forms/models.py | |
| parent | 45b73c9a4685809236f84046cc7ffd32a50db958 (diff) | |
gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.archive/attic/gis
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8215 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/models.py')
| -rw-r--r-- | tests/regressiontests/forms/models.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py index 98b9233d80..a6baa79811 100644 --- a/tests/regressiontests/forms/models.py +++ b/tests/regressiontests/forms/models.py @@ -1,6 +1,10 @@ +# -*- coding: utf-8 -*- import datetime from django.db import models +# Can't import as "forms" due to implementation details in the test suite (the +# current file is called "forms" and is already imported). +from django import forms as django_forms class BoundaryModel(models.Model): positive_integer = models.PositiveIntegerField(null=True, blank=True) @@ -14,8 +18,23 @@ class ChoiceModel(models.Model): """For ModelChoiceField and ModelMultipleChoiceField tests.""" name = models.CharField(max_length=10) +class FileModel(models.Model): + file = models.FileField(upload_to='/') + +class FileForm(django_forms.Form): + file1 = django_forms.FileField() + __test__ = {'API_TESTS': """ >>> from django.forms import form_for_model, form_for_instance +>>> from django.core.files.uploadedfile import SimpleUploadedFile + +# FileModel with unicode filename and data ######################### +>>> f = FileForm(data={}, files={'file1': SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह')}, auto_id=False) +>>> f.is_valid() +True +>>> f.cleaned_data +{'file1': <SimpleUploadedFile: 我隻氣墊船裝滿晒鱔.txt (text/plain)>} +>>> m = FileModel.objects.create(file=f.cleaned_data['file1']) # Boundary conditions on a PostitiveIntegerField ######################### >>> BoundaryForm = form_for_model(BoundaryModel) |
