Opened 9 years ago

Closed 9 years ago

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

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 9 years ago.

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by Adam Endicott

comment:1 Changed 9 years ago by mtredinnick

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

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

comment:2 Changed 9 years ago by adrian

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