diff --git a/model_utils/models.py b/model_utils/models.py index fdf13a2..da7e879 100644 --- a/model_utils/models.py +++ b/model_utils/models.py @@ -34,8 +34,12 @@ class TimeStampedModel(models.Model): modified field is updated even if it is not given as a parameter to the update field argument. """ - if 'update_fields' in kwargs and 'modified' not in kwargs['update_fields']: - kwargs['update_fields'] += ['modified'] + update_fields = kwargs.get('update_fields', None) + if update_fields is not None: + update_fields = set(update_fields) + if update_fields: + kwargs['update_fields'] = update_fields.union({'modified'}) + super().save(*args, **kwargs) class Meta: