Updated documentation for ChangeManipulators to reflect use of flatten_data() rather than __dict__ to populate form data.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3758 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2006-09-14 13:31:50 +00:00
parent 3c5782287e
commit 45399b4b13
1 changed files with 5 additions and 5 deletions

View File

@ -321,7 +321,7 @@ about editing an existing one? It's shockingly similar to creating a new one::
else: else:
errors = {} errors = {}
# This makes sure the form accurate represents the fields of the place. # This makes sure the form accurate represents the fields of the place.
new_data = place.__dict__ new_data = manipulator.flatten_data()
form = forms.FormWrapper(manipulator, new_data, errors) form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('places/edit_form.html', {'form': form, 'place': place}) return render_to_response('places/edit_form.html', {'form': form, 'place': place})
@ -336,10 +336,10 @@ The only real differences are:
* ``ChangeManipulator.original_object`` stores the instance of the * ``ChangeManipulator.original_object`` stores the instance of the
object being edited. object being edited.
* We set ``new_data`` to the original object's ``__dict__``. This makes * We set ``new_data`` based upon ``flatten_data()`` from the manipulator.
sure the form fields contain the current values of the object. ``flatten_data()`` takes the data from the original object under
``FormWrapper`` does not modify ``new_data`` in any way, and templates manipulation, and converts it into a data dictionary that can be used
cannot, so this is perfectly safe. to populate form elements with the existing values for the object.
* The above example uses a different template, so create and edit can be * The above example uses a different template, so create and edit can be
"skinned" differently if needed, but the form chunk itself is completely "skinned" differently if needed, but the form chunk itself is completely