summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-10 21:10:47 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-10 21:10:47 +0000
commitef48a3e69c02438db32f20531f5c679e8315d528 (patch)
treea60f57ad406aaa674ee8c742947872d2efc12cf4 /tests/regressiontests
parent94e8f4fb358fe39a67456f23f92eacd6f83e302d (diff)
Fixed #7830 -- Removed all of the remaining, deprecated, non-oldforms features:
* Support for representing files as strings was removed. Use `django.core.files.base.ContentFile` instead. * Support for representing uploaded files as dictionaries was removed. Use `django.core.files.uploadedfile.SimpleUploadedFile` instead. * The `filename`, `file_name`, `file_size`, and `chuck` properties of `UploadedFile` were removed. Use the `name`, `name`, `size`, and `chunks` properties instead, respectively. * The `get_FIELD_filename`, `get_FIELD_url`, `get_FIELD_size`, and `save_FIELD_file` methods for Models with `FileField` fields were removed. Instead, use the `path`, `url`, and `size` attributes and `save` method on the field itself, respectively. * The `get_FIELD_width` and `get_FIELD_height` methods for Models with `ImageField` fields were removed. Use the `width` and `height` attributes on the field itself instead. * The dispatcher `connect`, `disconnect`, `send`, and `sendExact` functions were removed. Use the signal object's own `connect`, `disconnect`, `send`, and `send` methods instead, respectively. * The `form_for_model` and `form_for_instance` functions were removed. Use a `ModelForm` subclass instead. * Support for importing `django.newforms` was removed. Use `django.forms` instead. * Support for importing `django.utils.images` was removed. Use `django.core.files.images` instead. * Support for the `follow` argument in the `create_object` and `update_object` generic views was removed. Use the `django.forms` package and the new `form_class` argument instead. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8291 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/forms/models.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py
index a6baa79811..42498cd4f9 100644
--- a/tests/regressiontests/forms/models.py
+++ b/tests/regressiontests/forms/models.py
@@ -25,7 +25,7 @@ class FileForm(django_forms.Form):
file1 = django_forms.FileField()
__test__ = {'API_TESTS': """
->>> from django.forms import form_for_model, form_for_instance
+>>> from django.forms.models import ModelForm
>>> from django.core.files.uploadedfile import SimpleUploadedFile
# FileModel with unicode filename and data #########################
@@ -37,21 +37,25 @@ True
>>> m = FileModel.objects.create(file=f.cleaned_data['file1'])
# Boundary conditions on a PostitiveIntegerField #########################
->>> BoundaryForm = form_for_model(BoundaryModel)
->>> f = BoundaryForm({'positive_integer':100})
+>>> class BoundaryForm(ModelForm):
+... class Meta:
+... model = BoundaryModel
+>>> f = BoundaryForm({'positive_integer': 100})
>>> f.is_valid()
True
->>> f = BoundaryForm({'positive_integer':0})
+>>> f = BoundaryForm({'positive_integer': 0})
>>> f.is_valid()
True
->>> f = BoundaryForm({'positive_integer':-100})
+>>> f = BoundaryForm({'positive_integer': -100})
>>> f.is_valid()
False
# Formfield initial values ########
If the model has default values for some fields, they are used as the formfield
initial values.
->>> DefaultsForm = form_for_model(Defaults)
+>>> class DefaultsForm(ModelForm):
+... class Meta:
+... model = Defaults
>>> DefaultsForm().fields['name'].initial
u'class default value'
>>> DefaultsForm().fields['def_date'].initial
@@ -59,14 +63,14 @@ datetime.date(1980, 1, 1)
>>> DefaultsForm().fields['value'].initial
42
-In form_for_instance(), the initial values come from the instance's values, not
-the model's defaults.
->>> foo_instance = Defaults(name=u'instance value', def_date = datetime.date(1969, 4, 4), value = 12)
->>> InstanceForm = form_for_instance(foo_instance)
->>> InstanceForm().fields['name'].initial
+In a ModelForm that is passed an instance, the initial values come from the
+instance's values, not the model's defaults.
+>>> foo_instance = Defaults(name=u'instance value', def_date=datetime.date(1969, 4, 4), value=12)
+>>> instance_form = DefaultsForm(instance=foo_instance)
+>>> instance_form.initial['name']
u'instance value'
->>> InstanceForm().fields['def_date'].initial
+>>> instance_form.initial['def_date']
datetime.date(1969, 4, 4)
->>> InstanceForm().fields['value'].initial
+>>> instance_form.initial['value']
12
"""}