コード例 #1
0
 def execute(self):
     files = glob.glob('/home/humitos/ciensonrisas/sonrisas/santa fe/*')
     files = sorted(files, key=lambda x: int(x.split('#')[1].split('.')[0]))
     for f in files:
         number = int(f.split('#')[1].split('.')[0])
         smile = Smile(number=number,
                       place=Place.objects.filter(name='Santa Fe')[0],
                       author=Author.objects.get(id=1))
         smile.photo = f
         smile.photo.save(f, ContentFile(open(f).read()))
         smile.save()
コード例 #2
0
 def execute(self):
     files = glob.glob('/home/humitos/ciensonrisas/sonrisas/gualeguaychu/*')
     files = sorted(files, key=lambda x: int(x.replace('\xcc\x81', '').split('#')[1].split(' ')[0]))
     for f in files:
         number = int(f.replace('\xcc\x81', '').split('#')[1].split(' ')[0])
         smile = Smile(number=number,
                       place=Place.objects.filter(name=u'Gualeguaychú')[0],
                       author=Author.objects.get(id=1))
         smile.photo = f
         smile.photo.save(f, ContentFile(open(f).read()))
         smile.save()