1
Django管理パネルから画像をアップロードしようとしているときにエラーが発生しました。Django管理者経由でImageFieldに画像をアップロードする際のエラー
fs = FileSystemStorage(location='/media')
class Picture(models.Model):
picture_path = models.ImageField(upload_to=fs, blank=True)
hunter_ID = models.ForeignKey(User,
on_delete=models.CASCADE,)
bounty_ID = models.ForeignKey('bountyhunt.Bounty',
on_delete=models.CASCADE,)
winner = models.BooleanField(default=False)
example_pic = models.BooleanField(default=False)
def __str__(self):
return self.picture_path
と私は取得していますエラーは次のとおりです:モデルがある
TypeError at /admin/hunt/picture/add/
__str__ returned non-string (type ImageFieldFile)
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/hunt/picture/add/
Django Version: 1.9.6
Exception Type: TypeError
Exception Value:
__str__ returned non-string (type ImageFieldFile)
Exception Location: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/encoding.py in force_text, line 76
Python Executable: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3
Python Version: 3.5.1
Python Path:
['/Users/michael/Documents/phoboh',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages']
任意のアイデア?