Opened 11 years ago

Closed 8 years ago

#22 closed defect (duplicate)

[patch] FileUploadField should allow for clearing the field

Reported by: Adrian Holovaty Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

It's currently not possible to clear the value of a FileUploadField.

Attachments (1)

file_del.patch (4.8 KB) - added by jlabath@… 11 years ago.
Patch for admin app to allow deleting of files.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 11 years ago by Wilson Miner

priority: lownormal

I'm setting this to normal priority - it's needed fairly often and should definitely be possible from the admin interface.

comment:2 Changed 11 years ago by Jacob

milestone: Version 1.0

comment:3 Changed 11 years ago by jlabath@…

Notes for file_del.patch.

  • I guess things will have to change for this to work in magic removal branch.
  • The solution provided works for me but suggestions how to improve it are welcome.
  • Needs more testing.

Changed 11 years ago by jlabath@…

Attachment: file_del.patch added

Patch for admin app to allow deleting of files.

comment:4 Changed 11 years ago by anonymous

it is not working for me (with Images ) so I've change it to:
##

obj = get_object_or_404(mod, pk=object_id)
try:

delete_f = getattr(obj, 'get_%s_filename' % attname)
f=delete_f()
os.remove(f)
obj.image=
obj.save()

##


of course it should be better way.

comment:5 Changed 11 years ago by anonymous

    obj = get_object_or_404(mod, pk=object_id)
    try:
        delete_f = getattr(obj, 'get_%s_filename' % attname)
        f=delete_f()
        os.remove(f)
        obj.image=''
        obj.save()

comment:6 Changed 11 years ago by anonymous

Resolution: fixed
Status: newclosed

comment:7 Changed 11 years ago by Adrian Holovaty

Resolution: fixed
Status: closedreopened

Reopening because it's not fixed.

comment:8 Changed 11 years ago by Russell Keith-Magee

Summary: FileUploadField should allow for clearing the field[patch] FileUploadField should allow for clearing the field

comment:9 Changed 11 years ago by Go

Type: enhancement

comment:10 Changed 10 years ago by bryanchow

Type: defect

comment:11 Changed 10 years ago by bryanchow

The proposed solution mentioned in my previous comment has been extended and submitted as a patch. Since the patch also addresses the problem of FileField not working properly when core=True, we've started a new ticket for it here: #2534.

comment:12 Changed 10 years ago by Jacob

Closing as duplicate of #2534 (which supersedes this one).

comment:13 Changed 10 years ago by Jacob

Resolution: duplicate
Status: reopenedclosed

comment:14 Changed 10 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:15 Changed 8 years ago by Christopher Lenz <cmlenz@…>

Resolution: duplicate
Status: closedreopened

As far as I can tell, this issue was never fixed, and #2534 was later closed as invalid.

Even with Django 1.0, newforms-admin, and the removal of core fields, it is not possible to have a model with an optional FileField, and remove the value/file associated with that field through the automatic admin. Which is what this ticket was really about if I'm not mistaken.

Granted, it is possible to do this by customizing the admin (i.e. a custom model admin with a custom model form, for every model where this is needed).

But is this not considered a common enough use case to support without customization? In all seriousness I'm perplexed by the apparent lack of requests for this.

comment:16 Changed 8 years ago by Brian Rosner

Resolution: duplicate
Status: reopenedclosed

FileUploadField no longer exists making this specific ticket invalid. However, Django should support the ability with FileField's in general. #7048 is what we will be doing in a future release of Django. Marking this a duplicate in favor of the other ticket due to the invalidness of this ticket applying to current day Django.

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