Kaydet (Commit) 6f229048 authored tarafından Attila Tovt's avatar Attila Tovt Kaydeden (comit) Tim Graham

Fixed #25547 -- Made Model.refresh_from_db() update FileField's instance.

üst f5af68ba
......@@ -202,6 +202,10 @@ class FileDescriptor(object):
file.field = self.field
file.storage = self.field.storage
# Make sure that the instance is correct.
elif isinstance(file, FieldFile) and instance is not file.instance:
file.instance = instance
# That was fun, wasn't it?
return instance.__dict__[self.field.name]
......
......@@ -792,6 +792,11 @@ class FileFieldTests(unittest.TestCase):
except OSError:
self.fail("Deleting an unset FileField should not raise OSError.")
def test_refresh_from_db(self):
d = Document.objects.create(myfile='something.txt')
d.refresh_from_db()
self.assertIs(d.myfile.instance, d)
class BinaryFieldTests(test.TestCase):
binary_data = b'\x00\x46\xFE'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment