Opened 10 years ago

Closed 7 years ago

#22 closed defect (duplicate)

[patch] FileUploadField should allow for clearing the field

Reported by: adrian Owned by: adrian
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@… 9 years ago.
Patch for admin app to allow deleting of files.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 10 years ago by wilson

  • priority changed from low to normal

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

comment:2 Changed 10 years ago by jacob

  • milestone set to Version 1.0

comment:3 Changed 9 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 9 years ago by jlabath@…

Patch for admin app to allow deleting of files.

comment:4 Changed 9 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 9 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 9 years ago by anonymous

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

comment:7 Changed 9 years ago by adrian

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening because it's not fixed.

comment:8 Changed 9 years ago by russellm

  • Summary changed from FileUploadField should allow for clearing the field to [patch] FileUploadField should allow for clearing the field

comment:9 Changed 9 years ago by Go

  • Type enhancement deleted

comment:10 Changed 9 years ago by bryanchow

  • Type set to defect

comment:11 Changed 9 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 9 years ago by jacob

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

comment:13 Changed 9 years ago by jacob

  • Resolution set to duplicate
  • Status changed from reopened to closed

comment:14 Changed 8 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

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

  • Resolution duplicate deleted
  • Status changed from closed to reopened

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 7 years ago by brosner

  • Resolution set to duplicate
  • Status changed from reopened to closed

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