Opened 16 years ago

Closed 16 years ago

#10044 closed (fixed)

FileField should accept assignment of File objects

Reported by: Marty Alchin Owned by: Marty Alchin
Component: File uploads/storage Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Currently, FileField attributes can only receive new File content by way of the save() method, which commits the file to storage immediately. In order to support model validation, and perhaps elsewhere, these attributes should be able to accept a File object directly and delay saving them to storage until the model instance is saved.

Attachments (2)

10044.diff (4.8 KB ) - added by Marty Alchin 16 years ago.
Updated FieldFile to accept File objects through attribute assignment, saving them automatically when the associated instance is saved
10044.2.diff (5.3 KB ) - added by Marty Alchin 16 years ago.
Removed the save_form_data() override in FileField, now that the standard behavior is sufficient for populating a model from a form (and delaying the save is better typically, anyway)

Download all attachments as: .zip

Change History (5)

by Marty Alchin, 16 years ago

Attachment: 10044.diff added

Updated FieldFile to accept File objects through attribute assignment, saving them automatically when the associated instance is saved

by Marty Alchin, 16 years ago

Attachment: 10044.2.diff added

Removed the save_form_data() override in FileField, now that the standard behavior is sufficient for populating a model from a form (and delaying the save is better typically, anyway)

comment:1 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [9766]) Fixed #10044: You can now assign directly to file fields (instance.filefield = somefile). Thanks, Marty Alchin.

comment:2 by AndrewIngram, 16 years ago

Patch needs improvement: set
Resolution: fixed
Status: closedreopened

The patch breaks the behavior of the width_field and height_field properties of ImageField when using the admin.

See this thread for details: http://groups.google.com/group/django-users/browse_thread/thread/6fb4b1e8ec37fda3/eaf739b883e66fcf#eaf739b883e66fcf

comment:3 by Alex Gaynor, 16 years ago

Resolution: fixed
Status: reopenedclosed

This bug has been fixed, please open a new ticket since thats a seperate issue(even if it's a consequence of this)(I think a ticket is already open).

Note: See TracTickets for help on using tickets.
Back to Top