[Answered ]-Minimal developer setup of sorl-thumbnail with Django 1.7

0👍

Both other answers correctly suggested problems with serving up media files. Here is the complete list of code changes that were required:

  1. I had glossed over the fact that MEDIA assets are not the same as STATIC assets. This answer is the one that tipped me off to the fact that sorl-thumbnail is relying on MEDIA_URL to form its URL, and accordingly, MEDIA_ROOT. For my development, I set the following:

    • MEDIA_URL = '/media/'
    • MEDIA_ROOT = '/tmp/media/'
  2. I used this snippet for URLconf changes for serving up the media files. At this point I put an image in the media directory and made sure my template could correctly reference it.

  3. By this point, I had manually removed the sorl-thumbnail generated thumbnails, but no permutation of settings and activity would regenerate them. I remembered that getting your key value store/database/cached images out of sync requires manual cleanup. The management command ./manage.py thumbnail cleanup did the job, and it began regenerating again.

  4. Also worth noting is that I did not have to set THUMBNAIL_KVSTORE at all, or setup any key value store.

I hope this helps get others get started faster in setting up their dev environment.

1👍

When you go into this directory ‘/cache/cf/43/’, do you actually see the file ‘cf43126f1f961593650b5df4791e329f.jpg’ in there?

If so, it may be returning a 404 because you are using the Django runserver (not sure if you are or not). If you are, it might be worth taking a look at how to serve media files in development mode, https://docs.djangoproject.com/en/1.7/howto/static-files/.

1👍

You don’t need to setup the cache backend initialy, you may need to setup serving the static files, please look at the django docs about serving MEDIA and STATIC resources.

But the most important, Django 1.7 Support was introduced in the 12.1c release.

Try first:

pip install sorl-thumbnail==12.1c

It’s also helpful that you set the debug thumbnail setting on your settings file:

THUMBNAIL_DEBUG = True

Leave a comment