diff options
| author | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-13 15:40:41 +0000 |
|---|---|---|
| committer | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-13 15:40:41 +0000 |
| commit | ca343fc0ac546822839e5737c30c887dd59176b3 (patch) | |
| tree | cee235426ff053deb8a29b9a5556333ff9f46bc6 /docs/forms.txt | |
| parent | 429a542cece57e837387c5d3978677fbf4ce52f3 (diff) | |
boulder-oracle-sprint: Merged rest of package to trunk [4719]
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4722 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/forms.txt')
| -rw-r--r-- | docs/forms.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/forms.txt b/docs/forms.txt index 8c40eeb997..f76f6d27ef 100644 --- a/docs/forms.txt +++ b/docs/forms.txt @@ -417,6 +417,27 @@ Here's a simple function that might drive the above form:: form = forms.FormWrapper(manipulator, new_data, errors) return render_to_response('contact_form.html', {'form': form}) +Implementing ``flatten_data`` for custom manipulators +------------------------------------------------------ + +It is possible (although rarely needed) to replace the default automatically +created manipulators on a model with your own custom manipulators. If you do +this and you are intending to use those models in generic views, you should +also define a ``flatten_data`` method in any ``ChangeManipulator`` replacement. +This should act like the default ``flatten_data`` and return a dictionary +mapping field names to their values, like so:: + + def flatten_data(self): + obj = self.original_object + return dict( + from = obj.from, + subject = obj.subject, + ... + ) + +In this way, your new change manipulator will act exactly like the default +version. + ``FileField`` and ``ImageField`` special cases ============================================== |
