Fixed #32098 -- Made FieldFile use FileField.attname.
Aftera93425a37f
FileDescriptor is a subclass of DeferredAttribute and uses FileField.attname to access the field data, so that custom subclasses can not only save data to files, but also represent the same data with a different data type by attaching FileFiled.name to a particular descriptor. Follow up toa93425a37f
.
This commit is contained in:
parent
079deba530
commit
6599608c4d
|
@ -86,7 +86,7 @@ class FieldFile(File):
|
|||
def save(self, name, content, save=True):
|
||||
name = self.field.generate_filename(self.instance, name)
|
||||
self.name = self.storage.save(name, content, max_length=self.field.max_length)
|
||||
setattr(self.instance, self.field.name, self.name)
|
||||
setattr(self.instance, self.field.attname, self.name)
|
||||
self._committed = True
|
||||
|
||||
# Save the object because it has changed, unless save is False
|
||||
|
@ -106,7 +106,7 @@ class FieldFile(File):
|
|||
self.storage.delete(self.name)
|
||||
|
||||
self.name = None
|
||||
setattr(self.instance, self.field.name, self.name)
|
||||
setattr(self.instance, self.field.attname, self.name)
|
||||
self._committed = False
|
||||
|
||||
if save:
|
||||
|
|
Loading…
Reference in New Issue