Django Model에 instance 추가

2021. 1. 31. 14:34파이썬/Django

import glob
import Image

def updateImage() :
    images = []
    images += glob.glob('./../*.tiff')
    images += glob.glob('./../*.png')
    for image in images :
        if Image.objects.filter(file=image).count() == 0 :
            Image(file=image).save()