Django

Code

Ticket #1756 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: Adam Endicott Assigned to: adrian
Milestone: Component: Admin interface
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

patch.diff (0.7 kB) - added by Adam Endicott on 05/03/06 13:47:14.

Change History

05/03/06 13:47:14 changed by Adam Endicott

  • attachment patch.diff added.

06/19/06 07:30:48 changed by mtredinnick

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

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

06/19/06 12:40:29 changed by adrian

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


Add/Change #1756 ([patch] FilePathField gives no blank option in admin when blank=True is set)




Change Properties
Action