Opened 19 years ago

Closed 16 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: no UI/UX: no

Description

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

Attachments (1)

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

Download all attachments as: .zip

Change History (17)

comment:1 by Wilson Miner, 19 years ago

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 by Jacob, 19 years ago

milestone: Version 1.0

comment:3 by jlabath@…, 19 years ago

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.

by jlabath@…, 19 years ago

Attachment: file_del.patch added

Patch for admin app to allow deleting of files.

comment:4 by anonymous, 19 years ago

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 by anonymous, 19 years ago

    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 by anonymous, 19 years ago

Resolution: fixed
Status: newclosed

comment:7 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: closedreopened

Reopening because it's not fixed.

comment:8 by Russell Keith-Magee, 19 years ago

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

comment:9 by Go, 18 years ago

Type: enhancement

comment:10 by bryanchow, 18 years ago

Type: defect

comment:11 by bryanchow, 18 years ago

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 by Jacob, 18 years ago

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

comment:13 by Jacob, 18 years ago

Resolution: duplicate
Status: reopenedclosed

comment:14 by (none), 18 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:15 by Christopher Lenz <cmlenz@…>, 16 years ago

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 by Brian Rosner, 16 years ago

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