diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index d441433..9c5cf65 100644
a
|
b
|
class ObjectC(models.Model):
|
317 | 317 | |
318 | 318 | def __unicode__(self): |
319 | 319 | return self.name |
| 320 | |
| 321 | # For testing .update + auto_now behaviour for #15566 |
| 322 | class LogEntry(models.Model): |
| 323 | name = models.CharField(max_length=50) |
| 324 | modify_ts = models.DateTimeField(auto_now=True) |
| 325 | modify_date = models.DateField(auto_now=True) |
| 326 | No newline at end of file |
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
index 93e0845..52bc974 100644
a
|
b
|
from models import (Annotation, Article, Author, Celebrity, Child, Cover, Detail
|
15 | 15 | DumbCategory, ExtraInfo, Fan, Item, LeafA, LoopX, LoopZ, ManagedModel, |
16 | 16 | Member, NamedCategory, Note, Number, Plaything, PointerA, Ranking, Related, |
17 | 17 | Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, Node, ObjectA, ObjectB, |
18 | | ObjectC) |
| 18 | ObjectC, LogEntry) |
19 | 19 | |
20 | 20 | |
21 | 21 | class BaseQuerysetTest(TestCase): |
… |
… |
class Queries4Tests(BaseQuerysetTest):
|
978 | 978 | Report.objects.create(name='r1', creator=a1) |
979 | 979 | Report.objects.create(name='r2', creator=a3) |
980 | 980 | Report.objects.create(name='r3') |
| 981 | |
| 982 | entry = LogEntry.objects.create(name='First entry', |
| 983 | modify_date=datetime.date(2000, 1, 1)) |
| 984 | self.entry_datetime = entry.modify_ts |
| 985 | self.entry_date = entry.modify_date |
981 | 986 | |
982 | 987 | def test_ticket7095(self): |
983 | 988 | # Updates that are filtered on the model being updated are somewhat |
… |
… |
class Queries4Tests(BaseQuerysetTest):
|
1032 | 1037 | [] |
1033 | 1038 | ) |
1034 | 1039 | |
| 1040 | def test_update_with_auto_now(self): |
| 1041 | # Ticket #15566. Make sure .update queries affect DateTimeField-s and |
| 1042 | # DateField-s with auto_now = True |
| 1043 | LogEntry.objects.update(name='First entry modified') |
| 1044 | entry = LogEntry.objects.get() |
| 1045 | self.assertEqual(entry.name, 'First entry modified') |
| 1046 | self.assertNotEqual(entry.modify_ts, self.entry_datetime, 'DateTime field of LogEntry should have been updated') |
| 1047 | self.assertNotEqual(entry.modify_date, self.entry_date, 'Date field of LogEntry should have been updated') |
1035 | 1048 | |
1036 | 1049 | class Queries5Tests(TestCase): |
1037 | 1050 | def setUp(self): |