Re: Package that helps update only changed fields

2019-06-24 Thread Dan Davis
Thanks, I wrote a mixin class for most of my forms that works a lot like this, although it combines self.changed_fields and self.model._meta.fields to discover which fields to update, rather than the two stages you have above. I discovered when trying to generalize this mixin that some of my

Re: Package that helps update only changed fields

2019-06-18 Thread Simon Charette
Hello Dan, I'm not aware of any third party library handling this but a simple way to achieve what you're after would be to subclass ModelForm in order to override save() and pass commit=False in your super() call. e.g. (untested) class UpdateFieldsModelForm(ModelForm): update_fields = None

Package that helps update only changed fields

2019-06-18 Thread Dan Davis
So, I recently observed that a Django ModelForm updates all columns when it is updating a model instance. This is appropriate for a typical situation where Django is also in control of the schema. I also see that you can control this behavior by passing update_fields