newforms FileField special file naming requirements
|Reported by:||Owned by:||nobody|
|Severity:||Keywords:||file naming newforms filefield, fs-rf|
|Cc:||jm.bugtracking@…, ross@…||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Would be nice if the FileField allowed files to be saved based on other attributes on the model.
This requires setting those attributes before the save_form_data (new in #3297) is called by the form to save the file.
The best would be to make this a spechial case that handles those fields last, not only FileFields but any field that requires other model data.
If the saving needs a pk, so the filename/dir of the file is based on the model instance pk. save_form_data shold be called right after commit and save the model instance again. Preferably once and not one save per field.
The problem with saving twice is if the field has null=False the insert would fail because of missing data on the instance, the solution would be to handle the field both before and after commit. Setting the attribute to before the insert, then saving the file on the update.
Change History (14)
comment:3 Changed 10 years ago by
|Component:||Uncategorized → django.newforms|
|Owner:||changed from Jacob to Adrian Holovaty|
|Triage Stage:||Unreviewed → Design decision needed|