I have trouble displaying the thumbnail image generated by Sorl-thumbnail. Here is my view.py:
def index(request):
if request.method == 'GET':
im = get_thumbnail('/Users/cheng/Dev/notes_proj/images/2015/4/8/c0eb6152bcb74c31c6eff3562513ee6507f8657d.png', '100x100')
context = {'im': im}
return render(request, 'index.html', context)
Here is my template:
{% load thumbnail %}
{% thumbnail im as img %}
<img src="{{ img.url }}">
{% endthumbnail %}
Here is the error message:
[09/Apr/2015 16:27:35] "GET /cache/51/03/5103e40af16185770a5928d7f5a5b31a.jpg HTTP/1.1" 404 13744
The THUMBNAIL_DEBUG = True is turned on and there is no error message from Sorl.
I am using the default database cache approach (which means no extra setup required besides adding sorl to INSTALLED_APP and run "python manage.py migrate")
I have searched my hard drive and there is no "/cache/51/03/5103e40af16185770a5928d7f5a5b31a.jpg"
My current setup does not allow me to use 'ImageField' in my model. So I simply stored the absolute path to the image file and used the low level API of sorl to generate the thumbail as shown above.
I saw this post: Sorl-thumbnail bad url's
I added the MEDIA_URL and MEDIA_ROOT to my settings.py:
MEDIA_URL = 'images/'
MEDIA_ROOT = os.path.join(BASE_DIR, '../images')
Still getting the 404 error:
09/Apr/2015 16:45:43] "GET /images/cache/51/03/5103e40af16185770a5928d7f5a5b31a.jpg HTTP/1.1" 404 13767
I checked the database table 'thumbnail_kvstore'. It is always empty.
I am using:
sorl-thumbnail (12.2) Django (1.7.7)
So which part did I do wrong?
Thanks a lot!