Opened 2 years ago

Closed 2 years ago

#20343 closed Uncategorized (needsinfo)

Model save() method needs a way to tell if a file upload occurred

Reported by: ewoudenberg Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This concerns editing objects from Django's admin interface that have FileFields.

Django's FileField handles uploading conveniently, but as far as I can tell does not allow you to determine in the save() method whether a file upload has just occurred, or whether instead no upload has occurred and the object is simply being saved with the previously used filename.

It would be nice if the FieldFile object provided some indicator that a file has been uploaded with the form.

In my case I need to do once-only processing on newly uploaded files and so need to know when uploads happen.

Change History (2)

comment:1 Changed 2 years ago by eaw@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by ptone

  • Resolution set to needsinfo
  • Status changed from new to closed

Given the range of things that one may choose to do or not do when a file is or is not attached, how could Django provide a standard hook for something like this.

This could be part of model validation - but currently is probably best handled by the form class that is receiving the file upload, that is where the "just occurred" part of the file upload is most clear.

I'm closing this as needsinfo for now - as it sounds to me like something that can be done currently, but you are hoping Django would do for you, but what is not articulated is what the common/universal need is, such that it be added to the framework itself.

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