Document how to change the path of a FileField
|Reported by:||simon29||Owned by:||jorgebg|
|Severity:||Normal||Keywords:||filefield imagefield path filename|
|Cc:||ledermann@…, kitsunde@…, cmawebsite@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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 (18)
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
comment:11 Changed 5 months ago by collinanderson
- Cc cmawebsite@… added
- Component changed from File uploads/storage to Documentation
- Easy pickings set
- Has patch unset
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Summary changed from FileField path isn't settable to Document how to change the path of a FileField
comment:12 Changed 4 months ago by timgraham
- Owner changed from simon29 to timgraham
- Status changed from new to assigned
comment:13 Changed 4 months ago by timgraham
- Owner timgraham deleted
- Status changed from assigned to new
comment:15 Changed 4 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from assigned to closed