Add dict.update() support to BaseDict.
This commit is contained in:
parent
12f884e3ac
commit
50d9b0b796
@ -1293,6 +1293,10 @@ class BaseDict(dict):
|
||||
self._mark_as_changed()
|
||||
super(BaseDict, self).popitem(*args, **kwargs)
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
self._mark_as_changed()
|
||||
super(BaseDict, self).update(*args, **kwargs)
|
||||
|
||||
def _mark_as_changed(self):
|
||||
if hasattr(self._instance, '_mark_as_changed'):
|
||||
self._instance._mark_as_changed(self._name)
|
||||
|
@ -772,6 +772,13 @@ class FieldTest(unittest.TestCase):
|
||||
# Confirm handles non strings or non existing keys
|
||||
self.assertEquals(BlogPost.objects.filter(info__details__test__exact=5).count(), 0)
|
||||
self.assertEquals(BlogPost.objects.filter(info__made_up__test__exact='test').count(), 0)
|
||||
|
||||
post = BlogPost.objects.create(info={'title': 'original'})
|
||||
post.info.update({'title': 'updated'})
|
||||
post.save()
|
||||
post.reload()
|
||||
self.assertEquals('updated', post.info['title'])
|
||||
|
||||
BlogPost.drop_collection()
|
||||
|
||||
def test_dictfield_strict(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user