Opened 3 years ago

Last modified 2 years ago

#19215 new Bug

ImageField's “Currently” and “Clear” Sometimes Don't Appear

Reported by: nrogers64@… Owned by: mcardillo55@…
Component: Forms Version: 1.4
Severity: Normal Keywords: ImageField
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes


I have found scenarios where an ImageField's “Currently” and “Clear” widgets don't appear. Here are the instructions to reproduce the scenarios:

Create an app called "imagefield_bug" and paste this in its "" file:

from django.db import models

class ImageFieldBug(models.Model):
    required_text_field = models.CharField(max_length=100)
    optional_image = models.ImageField(upload_to='images/', blank=True, null=True)

    def __unicode__(self):
        return self.required_text_field

Add the "imagefield_bug" app to your project's INSTALLED_APPS. Make sure "django.contrib.admin" is also in INSTALLED_APPS while you're at it.

Make sure the admin lines in "" are uncommented.

Run these commands:

printf "from django.contrib import admin\nfrom models import ImageFieldBug\n\\n" > imagefield_bug/

python syncdb

python runserver

Go to the following URL, log in, fill out both fields correctly, and click "Save and continue editing":

Now you should see the "Currently" and "Clear" widgets. Choose a non-image to upload and then click "Save". Now the "Currently" and "Clear" widgets are gone, potentially misleading the user into thinking the original image is gone forever.

Now click your browser's "Back" button, refresh the page, blank out the "Required text field" field, and either check the "Clear" checkbox or choose a valid image to upload. After that, click "Save". Again, the "Currently" and "Clear" widgets will be gone.

See this django-developers discussion for more information.

Change History (4)

comment:1 Changed 3 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Thanks for filing the report!

I've verified this behavior, and I think it is less-than-optimal. The path to fixing it isn't entirely clear, though.

comment:2 Changed 3 years ago by mcardillo55@…

  • Has patch set
  • Owner changed from nobody to mcardillo55@…
  • Triage Stage changed from Accepted to Unreviewed

comment:3 Changed 3 years ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

"Unreviewed" is about the ticket, not the patch. Checking "Has patch" is enough.

comment:4 Changed 2 years ago by timo

  • Has patch unset

Link to patch gives a 404.

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