﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22981	Fields with auto_now=True are not updated if the field name is not present in update_fields list passed into Model.save	Josh Crompton	nobody	"Passing `update_fields` into a model's `save` method fails to update fields on the model which have `auto_now=True` specified but which are not included in the `update_fields` parameter.

I think it's a fairly common use case to have a base model which records when the instance was last updated:

{{{
#!div style=""font-size: 80%""
Code highlighting:
  {{{#!python
    class MyModel(models.Model):
        updated_at = models.DateTimeField(auto_now=True)
  }}}
}}}

But, now I have to remember to always include `updated_at` in my list of `updated_fields`:

{{{
#!div style=""font-size: 80%""
Code highlighting:
  {{{#!python

In [2]: m = MyModel.objects.latest('updated_at')

In [3]: m.updated_at
Out[3]: datetime.datetime(2014, 7, 9, 1, 12, 12, 850847, tzinfo=<UTC>)

In [4]: m.save()

In [5]: m.updated_at
Out[5]: datetime.datetime(2014, 7, 9, 1, 12, 12, 850847, tzinfo=<UTC>)

In [6]: m.save(update_fields=['updated_at'])

In [7]: m.updated_at
Out[7]: datetime.datetime(2014, 7, 9, 2, 21, 48, 412890, tzinfo=<UTC>)

  }}}
}}}


So if I have an instance of a subclass of this model and only want to update some unrelated field on that subclass, then I have to a) know that it inherits from `MyModel` and b) know that `MyModel` has a field with `auto_now=True` and what that field's name is and c) remember to include that in the `updated_fields` list whenever I use it. This seems like a lot of overhead!

Ticket #15566 addresses a similar problem (but covers the case of using `Manager.update`, rather than `Model.save`) and was determined to be a documentation issue largely because `Manager.update` is for updating multiple rows with a single SQL statement whereas `auto_now` and friends involve per-row calculations.

Since `Model.save` is only updating a single row, that argument doesn't hold in this case, so I'm inclined to think this is a bug rather than a documentation issue."	Bug	closed	Database layer (models, ORM)	3.1	Normal	wontfix			Unreviewed	0	0	0	0	0	0
