Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1756 closed defect (fixed)

[patch] FilePathField gives no blank option in admin when blank=True is set

Reported by: Adam Endicott 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

I have a model with this field:

image = models.FilePathField(path='/my/path', blank=True, null=True)

In the admin interface, the image field shows up dimmed like the rest
of the optional fields. However the select list lists all the files in
/my/path, without any blank option. So you are in effect forced to
select a file.

The patch adds models.BLANK_CHOICE_DASH to the choices list if is_required is false.

(django-users thread: http://groups.google.com/group/django-users/browse_frm/thread/9988c0119c95dda9/#)

Attachments (1)

patch.diff (749 bytes ) - added by Adam Endicott 19 years ago.

Download all attachments as: .zip

Change History (3)

by Adam Endicott, 19 years ago

Attachment: patch.diff added

comment:1 by Malcolm Tredinnick, 19 years ago

Resolution: fixed
Status: newclosed

(In [3146]) Fixed #1756 -- Permit selecting no file in a FilePathField with blank = True.
Thanks to Adam Endicott for the patch.

comment:2 by Adrian Holovaty, 19 years ago

This patch is unacceptable because the form layer shouldn't be importing from the database layer.

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