无法连接“str”和“ImageFieldFile”对象
filename = settings.MEDIA_ROOT + self.image
在 Debian Linux 服务器上运行 Python 2.5 (Django 1.3)。
最佳答案
使用image.name
:
filename = self.image.name
If you wanted to retrieve the uploaded file's on-disk filename, or the file's size, you could use the name and size attributes respectively; for more information on the available attributes and methods, see the File class reference and the Managing files topic guide.
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField
关于django - 无法连接 'str' 和 'ImageFieldFile' 对象 Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6175906/