jazzband / django-floppyforms

Full control of form rendering in the templates.
http://django-floppyforms.readthedocs.org/
Other
839 stars 145 forks source link

FileField with None value throws ValueError in template rendering #128

Closed mtirsel closed 9 years ago

mtirsel commented 10 years ago

If using an ImageField with value None, the template rendering ends with ValueError (The 'picture' attribute has no file associated with it.). If the value is empty string for the ImageField, then the rendering is ok.

I was not able to debug the issue in more detail, but accessing field.url from shell ends always with ValueError for both values (None or empty string), but with empty string, the error is somehow ignored in template rednering (it's a little bit harder to debug rendering of templates).

This should be fixed at least in clearable_input.html:

{% if value.url %}

to

{% if value and value.url %}
gregmuellegger commented 9 years ago

FYI: I just released floppyforms 1.3 including a fix to this bug.