title: How do I use Django, sorl-thumbnail, memcached, and S3 together?
body: <p>I've got a project in which I need to start creating dynamically-resized thumbnails of user-uploaded images, where previously I'd been generating some specifically sized ones. I have an existing model, which represents an image which looks like this:</p>
  
  <pre><code>class Image(models.Model):
    original = models.URLField()
    small = models.URLField()
    medium = models.URLField()
    large = models.URLField()
  </code></pre>
  
  <p>Each of those is filled in with a URL to the respective image on S3. At the time of upload, all the versions are created (actually shortly after, via a scheduled task), stored in S3, and then set on the model. Going forward, our design needs many different sizes for each thumbnail, so storing them all in the db is not practical. I'd like to just keep <code>original</code> and do the rest on-the-fly in the templates.</p>
  
  <p>So this is where I come to <a href="https://github.com/sorl/sorl-thumbnail" rel="noreferrer">sorl-thumbnail</a>. It seems to be intended to do what I want, but I'm kind of lost as to how it's supposed to be working (it's not at the moment). As a test I've taken made a basic view/template which lists some images and attempts to thumbnail them, much like the tutorial:</p>
  
  <pre><code>{% for img in image_set %}
    {% thumbnail img.original "180x180" crop="center" format="PNG" as im %}
    &lt;img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"&gt;
    {% endthumbnail %}
  {% endfor %}
  </code></pre>
  
  <p>That ends up generating a URL for the file like <code>cache/84/8f/848fb078f2e8d35aecd92150c6fa6843.png</code> (which 404s). I'm not sure I understand where this file is supposed to be getting stored. I am assuming it is pulling in the S3 file and then creating the thumbnail <em>somewhere</em>, but I am unclear where that is, and where I am supposed to be serving it from. This is all on the local devserver right now, using memcached (in which I can see is getting cache entries set). PIL is installed in my environment with jpeg/png support.</p>