add import script for image folders
This commit is contained in:
parent
3437e65089
commit
d83b8dc03e
22
urbstudio/urb/imports.py
Normal file
22
urbstudio/urb/imports.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from models import *
|
||||||
|
from django.core.files import File
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
def importFile(filePath, project):
|
||||||
|
f = File(open(filePath))
|
||||||
|
pi = ProjectImage()
|
||||||
|
pi.project = project
|
||||||
|
pi.image = f
|
||||||
|
pi.caption = ''
|
||||||
|
pi.save()
|
||||||
|
print "%s saved" % filePath
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def doDir(dirpath, project):
|
||||||
|
for f in glob("%s/*" % dirpath):
|
||||||
|
importFile(f, project)
|
||||||
|
print "all done"
|
||||||
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user