Django

Code

Ticket #22 (closed: duplicate)

Opened 4 years ago

Last modified 9 months ago

[patch] FileUploadField should allow for clearing the field

Reported by: adrian Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

Attachments

file_del.patch (4.8 kB) - added by jlabath@gmail.com on 03/13/06 23:27:49.
Patch for admin app to allow deleting of files.

Change History

07/28/05 16:02:25 changed 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.

09/25/05 17:29:09 changed by jacob

  • milestone set to Version 1.0.

03/13/06 23:26:38 changed by jlabath@gmail.com

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.

03/13/06 23:27:49 changed by jlabath@gmail.com

  • attachment file_del.patch added.

Patch for admin app to allow deleting of files.

03/21/06 22:19:32 changed 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.

03/21/06 22:21:13 changed 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()

04/10/06 12:38:00 changed by anonymous

  • status changed from new to closed.
  • resolution set to fixed.

04/10/06 12:45:06 changed by adrian

  • status changed from closed to reopened.
  • resolution deleted.

Reopening because it's not fixed.

04/17/06 08:32:15 changed by russellm

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

06/12/06 05:44:15 changed by Go

  • type deleted.

08/09/06 22:03:53 changed by bryanchow

  • type set to defect.

08/14/06 01:53:01 changed 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.

11/06/06 17:08:30 changed by jacob

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

11/06/06 22:06:48 changed by jacob

  • status changed from reopened to closed.
  • resolution set to duplicate.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

09/26/08 09:24:27 changed by Christopher Lenz <cmlenz@gmx.de>

  • status changed from closed to reopened.
  • resolution deleted.

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.

10/05/08 22:46:01 changed by brosner

  • status changed from reopened to closed.
  • resolution set to duplicate.

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.


Add/Change #22 ([patch] FileUploadField should allow for clearing the field)




Change Properties
Action