Skip to content Skip to sidebar Skip to footer

Django Imagefield Not Rendering Clearablefileinput

Starting to beat my head against the wall...perhaps I am missing something simple. models.py class GFImage(models.Model): image = models.ImageField(upload_to = 'uploads', null=

Solution 1:

The ClearableFileInput will only display the clear checkbox when there's an initial file selected. Looking at your form, it looks like a a new form without initial data, so the checkbox won't be displayed.

defrender(self, name, value, attrs=None):
    .. snip ..
    if value andhasattr(value, "url"):
        template = self.template_with_initial
        substitutions['initial'] = format_html(self.url_markup_template,

https://github.com/django/django/blob/5fda9c9810dfdf36b557e10d0d76775a72b0e0c6/django/forms/widgets.py#L372

Post a Comment for "Django Imagefield Not Rendering Clearablefileinput"