0
我嘗試在模型中覆蓋save()方法。如何正確執行此操作?在模型中重寫save()方法。如何正確執行此操作?
import Image
from tesseract import image_to_string
class FileModel(models.Model):
user = models.ForeignKey(User)
base_file = models.FileField(upload_to="files")
after_file = models.FileField(upload_to="file_ocr", blank=True, null=True)
def save(self):
after_file = image_to_string(Image.open('base_file'), lang='en')
after_file.save()
super(FileModel, self).save()
如果創建base_file
我需要用image_to_string()
方法和保存導致像after_file
。
創建只有當或每次它保存? –