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)
Change History (17)
comment:1 by , 19 years ago
priority: | low → normal |
---|
comment:2 by , 19 years ago
milestone: | → Version 1.0 |
---|
comment:3 by , 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.
comment:4 by , 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 , 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 , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 19 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopening because it's not fixed.
comment:8 by , 19 years ago
Summary: | FileUploadField should allow for clearing the field → [patch] FileUploadField should allow for clearing the field |
---|
comment:9 by , 19 years ago
Type: | enhancement |
---|
comment:10 by , 18 years ago
Type: | → defect |
---|
We're proposing a solution to this issue here:
http://www.verdjn.com/wiki/FileField
http://groups.google.com/group/django-developers/browse_thread/thread/3043e6331054d7c3
Comments please :)
comment:11 by , 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:13 by , 18 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
comment:15 by , 16 years ago
Resolution: | duplicate |
---|---|
Status: | closed → 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 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → 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.
I'm setting this to normal priority - it's needed fairly often and should definitely be possible from the admin interface.