1π
β
At first for your model you should create an image field and in there you should define where you want to upload your image:
class mymodel(models.Model):
name = models.CharField(max_length=50)
my_image = models.ImageField(blank=True, null=True,upload_to='/home/user/webapps/project/uploads/')
After that in your template when you want to show your image after getting your model object from your database try this:
<img src="{{ mymodel.my_image.url }}" alt="{{ mymodel.name }}" width="150" height="200" />
π€hamidfzm
Source:stackexchange.com