FileField path isn't settable
|Reported by:||simon29||Owned by:||simon29|
|Severity:||Normal||Keywords:||filefield imagefield path filename|
|Cc:||ledermann@…, kitsunde@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
Currently we can't set filefield/imagefield's underlying filename, without loading the file and feeding it's contents into save(). Obviously this is grossly inefficient.
This is a simple patch that allows you to set the path like so --
instance.myfile.path = 'uploads/new-path.avi'
Previously, instance.myfile.path is read only. If you set instance.myfile then instance.myfile.path etc will raise a ValueError, The 'myfile' attribute has no file associated with it.
Works with FileField, ImageField, and anything else that uses a File object that is subclassed from FieldFile.
Check stackoverflow, google, etc- lots of people banging their heads trying to figure out why they can't simply set the filename.
Change History (11)
Changed 4 years ago by simon29
comment:1 Changed 4 years ago by russellm
- Needs documentation set
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Design decision needed