Re: ImageField's “Currently” and “Clear” Sometimes Doesn't Appear

456 views
Skip to first unread message

Carl Meyer

unread,
Oct 30, 2012, 2:01:05 PM10/30/12
to django-d...@googlegroups.com
Hi Nick,

On 10/30/2012 08:21 AM, Nick wrote:
> I posted this question to Stack Overflow a couple weeks ago (link
> <http://stackoverflow.com/questions/12902785/imagefields-currently-and-clear-sometimes-doesnt-appear>)
> but have had no responses. I'm guessing it's geared more towards the
> Django developers, so I'm going to post it here.
>
> Assume you have a model that has a required field of any type and also
> an optional ImageField. Let's say you used Django's built-in admin
> interface to insert a row into this database table and when you did so,
> you filled out both fields. Now let's say you go to edit the row that
> you just created. The ImageField will look like this:
>
> Currently: [url] | [checkbox] Clear
>
> Change: [file widget]
>
> If you upload a non-image (a PDF, for example), it will say "Upload a
> valid image. The file you uploaded was either not an image or a
> corrupted image." only now the "Currently: [url] | [checkbox] Clear"
> portion won't be there anymore. This can be misleading to users (causing
> them to think the original image is now gone).
>
> Another issue is let's say you were editing the row and you blanked out
> the required field and also replaced the image with another one. It
> will, of course, complain about the required field not being filled out.
> But, again, the "Currently: [url] | [checkbox] Clear" portion of the
> image field won't be there anymore. Again, this can mislead the user.
>
> Is this a bug or is this the intended behavior? Either way, how can I
> get around this?

I can reproduce this, and I'd call it a bug. I think the fix may involve
passing the "initial" value to the ClearableFileInput in preference to
the value from the form submission, in cases where a bound form is being
rendered (because the ClearableFileInput widget can't do anything useful
with an unsaved value anyway), but it's not immediately clear to me how
to do that without introducing some unsavory widget-type-checking into
BoundField. So I think the right fix here may take some thought.

I searched the bug-tracker at code.djangoproject.com and didn't find an
existing bug for this - do you mind filing a bug for it?

Thanks!

Carl

Nick

unread,
Oct 30, 2012, 6:47:28 PM10/30/12
to django-d...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages