I've Images in my project folder created automatically and I want to upload these images to my MySQL DB. These images are named img0.png, img1.png.. etc
What I am currently doing :
views.py
for i in range(imageCount):
img = open("img%s.png" %i)
obj = userImages(userId = userid, images=img)
obj.save()
models.py
class userImages(models.Model):
userId = models.IntegerField()
images = models.ImageField()
This doesn't work. How can I make it work??