summaryrefslogtreecommitdiff
path: root/tests/modeltests/model_forms
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modeltests/model_forms')
-rw-r--r--tests/modeltests/model_forms/models.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index e8598bd68f..cc9efd0f94 100644
--- a/tests/modeltests/model_forms/models.py
+++ b/tests/modeltests/model_forms/models.py
@@ -79,8 +79,8 @@ class ImageFile(models.Model):
return self.description
__test__ = {'API_TESTS': """
->>> from django import newforms as forms
->>> from django.newforms.models import ModelForm
+>>> from django import forms
+>>> from django.forms.models import ModelForm
>>> from django.core.files.uploadedfile import SimpleUploadedFile
The bare bones, absolutely nothing custom, basic case.
@@ -113,7 +113,7 @@ Replacing a field.
... model = Category
>>> CategoryForm.base_fields['url'].__class__
-<class 'django.newforms.fields.BooleanField'>
+<class 'django.forms.fields.BooleanField'>
Using 'fields'.
@@ -211,7 +211,7 @@ We can also subclass the Meta inner class to change the fields list.
# Old form_for_x tests #######################################################
->>> from django.newforms import ModelForm, CharField
+>>> from django.forms import ModelForm, CharField
>>> import datetime
>>> Category.objects.all()
@@ -605,7 +605,7 @@ the data in the database when the form is instantiated.
# ModelChoiceField ############################################################
->>> from django.newforms import ModelChoiceField, ModelMultipleChoiceField
+>>> from django.forms import ModelChoiceField, ModelMultipleChoiceField
>>> f = ModelChoiceField(Category.objects.all())
>>> list(f.choices)
@@ -992,4 +992,22 @@ True
u'...test3.png'
>>> instance.delete()
+# Media on a ModelForm ########################################################
+
+# Similar to a regular Form class you can define custom media to be used on
+# the ModelForm.
+
+>>> class ModelFormWithMedia(ModelForm):
+... class Media:
+... js = ('/some/form/javascript',)
+... css = {
+... 'all': ('/some/form/css',)
+... }
+... class Meta:
+... model = PhoneNumber
+>>> f = ModelFormWithMedia()
+>>> print f.media
+<link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />
+<script type="text/javascript" src="/some/form/javascript"></script>
+
"""}