Доброго времени суток!
Помогите разобраться пожалуйста с sorl.thumbnail.get_thumbnail
.
Произвожу полную очистку enter code here
Использую в функции представления:
def thumb(request, id):
try:
intID = int(id)
interior = Interior.objects.get(id=intID)
thumbnail_width = settings.THUMBNAIL_DIMENSIONS['WIDTH']
thumbnail_height = settings.THUMBNAIL_DIMENSIONS['HEIGHT']
geometry = "%dx%d" % (thumbnail_width, thumbnail_height)
thumb = get_thumbnail(interior, geometry, crop='center')
print(thumb.url)
except ValueError:
return HttpResponse('')
except Exception as e:
print('Exception: ' + str(e))
return HttpResponse(thumb.read(), content_type='image/jpg')
В результате получаю
FileNotFoundError at /thumb/1/
[Errno 2] No such file or directory: 'D:\Work\Python\VisualizationSite\visite\files\cache\5f\8d\5f8d35cf36e4c49fb8f3af6bc0a90be6.jpg'
Request Method: GET
Request URL: http://localhost:8000/thumb/1/
Django Version: 1.8.2
Exception Type: FileNotFoundError
Exception Value:
[Errno 2] No such file or directory: 'D:\Work\Python\VisualizationSite\visite\files\cache\5f\8d\5f8d35cf36e4c49fb8f3af6bc0a90be6.jpg'
Exception Location: D:\Work\Python\VisualizationSite\lib\site-packages\django\core\files\storage.py in _open, line 202
Python Executable: D:\Work\Python\VisualizationSite\Scripts\python.exe
Python Version: 3.4.3
Python Path:
['D:\Work\Python\VisualizationSite\visite',
'C:\Windows\SYSTEM32\python34.zip',
'D:\Work\Python\VisualizationSite\DLLs',
'D:\Work\Python\VisualizationSite\lib',
'D:\Work\Python\VisualizationSite\Scripts',
'C:\Python34\Lib',
'C:\Python34\DLLs',
'D:\Work\Python\VisualizationSite',
'D:\Work\Python\VisualizationSite\lib\site-packages']
Server time: Вс, 24 Май 2015 10:54:12 +0300
И в папке cache ничего не создается
В настройках THUMBNAIL_CACHE = os.path.join(BASE_DIR, 'cache')
Updated 24 May 2015, 11:01 by SES.