if a file is present display, else display the default in django template <p>I have to display some 5000 images, My models.py has a field imagename, which contains the name of the image in the folder. But the problem is: corresponding to all the imagenames, images do not exist, in that case i want a default image say def.jpeg to be displayed, how can i do this? say the variable obj.image has the image name, if doesnot exist then i want to display the default.jpeg</p> <p>in short:</p> <pre><code>{% if obj.image %} // don't get confused, every obj.image has a name, but not necessarily a file corresponding to it &lt;img src="{{ STATIC_URL }}images/{{dish.image}}" width=150px /&gt; {% else %} &lt;img src="somedefaultimage.jpg" /&gt; </code></pre> <p>Models.py:</p> <pre><code>class ImageApp(models.Model): class Meta: db_table = "basetable" ordering = ['name'] def __unicode__(self): return self.name #imported_pk = models.IntegerField() # category_name = models.CharField(max_length=100) category = models.ForeignKey(Category,null=True,blank=True) something = models.CharField(max_length = 100, null=True, blank=True) name = models.CharField(max_length = 100) instructions = models.TextField() image = models.CharField(max_length=100, null=True, blank=True) </code></pre>