Code

#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

Description

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.

Attachments (0)

Change History (2)

comment:1 Changed 12 months ago by eaw@…

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

comment:2 Changed 12 months 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.