mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
[1.4.X] Fixed #15566 - Documented that update() doesn't honor DateField.auto_now
Thanks Shabda Raaj for the draft patch.
Backport of dc01e41d23
from master
This commit is contained in:
parent
7e8483e70b
commit
b0e2cb8e47
2 changed files with 10 additions and 9 deletions
|
@ -968,11 +968,12 @@ Be aware that the ``update()`` method is converted directly to an SQL
|
|||
statement. It is a bulk operation for direct updates. It doesn't run any
|
||||
:meth:`~django.db.models.Model.save` methods on your models, or emit the
|
||||
``pre_save`` or ``post_save`` signals (which are a consequence of calling
|
||||
:meth:`~django.db.models.Model.save`). If you want to save every item in a
|
||||
:class:`~django.db.models.query.QuerySet` and make sure that the
|
||||
:meth:`~django.db.models.Model.save` method is called on each instance, you
|
||||
don't need any special function to handle that. Just loop over them and call
|
||||
:meth:`~django.db.models.Model.save`::
|
||||
:meth:`~django.db.models.Model.save`), or honor the
|
||||
:attr:`~django.db.models.DateField.auto_now` field option.
|
||||
If you want to save every item in a :class:`~django.db.models.query.QuerySet`
|
||||
and make sure that the :meth:`~django.db.models.Model.save` method is called on
|
||||
each instance, you don't need any special function to handle that. Just loop
|
||||
over them and call :meth:`~django.db.models.Model.save`::
|
||||
|
||||
for item in my_queryset:
|
||||
item.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue