mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-17 04:10:24 +00:00
update implementation of TimeStampedModel.save to handle various ways of specifying 'update_fields'
This commit is contained in:
parent
fdd3af34d9
commit
e9c45c71d1
1 changed files with 6 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue