On Jun 10, 5:27 pm, Paolo Corti <pco...@gmail.com> wrote: > Hi > is it possible to update an object with a dictionary? > > I tried something like this: > myobject.save(force_update=True, **my_dict) > > getting an error, though: > TypeError at ... > save() got an unexpected keyword argument 'myfieldname' > > I wouldn't like to iterate the dictionary, neither to delete and > create the object again using the dictionary, is there a best > approach? > > thanks > Paolo
The error is in passing the dictionary to the save() method. If you've got an existing object and you want to update it, this will work: my_object.__dict__.update(my_dict) myobject.save() -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---