On 4/18/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Is there an example of a CHANGE Custom Manipulator? > At http://www.djangoproject.com/documentation/forms/ > I found only ADD Custom Manipulator.
The example on this page, under the "Custom forms and manipulators" heading, isn't really an Add *or* a Change manipulator, as it doesn't deal with data in the database at all (it is only used for sending email out when the form is completed correctly) If you wanted to create a real Change manipulator, you would have to do a couple of things differently -- First, the __init__ method needs to take an object, or at least a key. Something like this: def __init__(self, key): self.original = self.manager.get(pk=key) # define your self.fields here Secondly, you would need to implement a save() method, since the default in formfields.Manipulator is just to pass. The save method has to take the fields from the new_data dictionary, assign them to fields in the original object, and call original.save(). Alternately, I think you could subclass yourmodel.ChangeManipulator, and override the methods in there that you need to change, but I've never tried it that way :) Regards, Ian Clelland <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---