I am trying to preview image before uploading it to the html page. I am using django. This is my model
class Product(models.Model):
image = models.ImageField(upload_to='uploads/')
thumbnail = models.ImageField(upload_to='uploads/')
class Meta:
ordering = ['-date_added']
this is my form.py
class ProductForm(ModelForm):
class Meta:
model = Product
fields = ['image']
and this is my html page
<form method="post" action="." enctype="multipart/form-data">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="fieldWrapper">
{{ form.image.errors }}
<br>
<label for="{{ form.image.id_for_label }}"><br>       Image: </label>
{{ form.image }}
</div>
<div class="field">
<div class="control" style="margin-bottom: 3%">
<button class="btn btn-theme" style="float:right;">SUBMIT</button>
</div>
</div>
</form>
I am able to upload and display the image in the html page but i want it so that before i upload i can see the image i am trying to upload. How can i do that?