Skip to content
Advertisement

django forms don’t show clear image button

I have a Django form modalform. There is an image field in it. The issue is that when the user clicks on the clear image, the image is removed from the models, but when the html file tries to retrieve the image, an error message appears The 'image' attribute has no file associated with it.

So I’m planning to remove the clear button from django forms or is there any other best practises?

Advertisement

Answer

{%% if obj.image %%}
     <img src="{{ obj.image.url }}">
{%% else %%}
     your html content which you want to display after removing picture.
{%% endif %%}

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement