diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-07-19 13:30:47 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-07-19 13:30:47 +0000 |
| commit | 149e731c3c5a2cc96b7d3c72070401df6c2a238e (patch) | |
| tree | 2a819f695246ab36139b7f8846085c9df1563bd8 /tests/modeltests/model_forms | |
| parent | 5bf3565a263533e37b2e1217e8d447cb7e02f5b4 (diff) | |
gis: Merged revisions 7921,7926-7928,7938-7941,7945-7947,7949-7950,7952,7955-7956,7961,7964-7968,7970-7978 via svnmerge from trunk.
This includes the newforms-admin branch, and thus is backwards-incompatible. The geographic admin is _not_ in this changeset, and is forthcoming.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7979 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/model_forms')
| -rw-r--r-- | tests/modeltests/model_forms/models.py | 28 |
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> + """} |
