Opened 14 years ago

Closed 14 years ago

Last modified 14 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


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:

Attachments (1)

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

Download all attachments as: .zip

Change History (3)

Changed 14 years ago by Adam Endicott

Attachment: patch.diff added

comment:1 Changed 14 years ago by Malcolm Tredinnick

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 Changed 14 years ago by Adrian Holovaty

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