def manage_photo(request, obj_id):
form = MediaFileForm(instance=obj)
if request.method == "POST":
# Some actions here
# ...
return render(request, 'manage_photo.html', {'form': form,})
I would like to display an image thumbnail next to its form field on the form page. For that purpose I use easy-thubmnails module. I would like to write something like this in template:
<img src="{{ form.image|thumbnail_url:'small' }}">
But I can't, because {{ form.image }} is not a File
object, which thumbnail_url
filter takes as an argument.
I would appreciate any suggestion.
Since you initialized the form with an instance, you can access that instance: form.instance.image
.