Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Improvement for easy thumbnails backend #35

wants to merge 5 commits into from

5 participants


I improved the backend for easy thumbnails and changed that file's name to It solves the import name problem. Also I added some more options for easy thumbnails.
To make uploaded file unique, I used uuid to generate a sub directory for local backend.


Hey Michael,

Thanks for the contribution! A couple questions:

  • What "import name problem" is this fixing?
  • Can you clarify the use of UPLOAD_DIR? Is this an easy_thumbnails standard? (I'm not an easy thumbnails user, myself)
  • Any reason you've added UPLOAD_DIR to local, instead of just the easy thumbnails backend?



I tried to use the old easy thumbnails backend, but my django give me an error. No module named files in easy_thumbnails. I guess the reason is the backend file ( has the same name with app name of easy thumbnails, and this confuses python.
And I don't know why, but update_filename function doesn't work for easy thumbnails backend. So uploading images may have conflict filenames. Therefore I use uuid to generate a random string as a sub dir under UPLOAD_DIR to solve the potential filename conflict when using easy thumbnails.


Hey Michael,

You should be able to get around that error by being more explicit in your import:

from ajaxuploader.backends import easy_thumbnails

If you want it and the easy_thumbnails library in the same file, you'd do something like:

from ajaxuploader.backends import easy_thumbnails as backend_thumbnails

Changing the name in this library breaks backwards compatibility for existing users, so I'm inclined against it.

As for the update_filename issue, it'd be great to get a test of what's failing, so we can fix it in the way that makes sense. At the least, I don't see anything that suggests you couldn't add UPLOAD_DIR to the easy_thumbnail backend, or even better, fix the issue with update_filename - it's there to solve exactly this problem!

For what it's worth, I'm using update_filename in a couple instances (mostly S3 backend), with custom overrides, and it's working for me. Would love better test coverage on this to help me be sure it works, but there's only so much time in the day.

Big takeaways:

  • unless there are other reasons I'm missing on the name, I'd prefer to leave it as easy_thumbails.
  • I'd prefer to see how update_filename is failing, and have the fix there. Your UUID idea's interesting, and could be a proposal to change the existing default if it's what's broken.

Thanks for helping make ajax-uploader better!



Yep, the same problem here:
from views import avatar_uploader
File "/Users/bashu/Projects/prodavalco/accounts/", line 4, in
from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
File "/Users/bashu/.virtualenvs/prodavalco/lib/python2.7/site-packages/ajaxuploader/backends/", line 4, in
from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files

easy_thumbnails backend is broken! Forking...


+1 on import issue:

Traceback (most recent call last):
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/handlers/", line 103, in get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/", line 319, in resolve
    for pattern in self.url_patterns:
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/", line 347, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/", line 342, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/utils/", line 35, in import_module
  File "/Users/dimus/Projects/", line 8, in <module>
    from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/ajaxuploader/backends/", line 4, in <module>
    from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files

+1 on broken easy thumbnails backend. I have same stack trace as applecat above me. Would like to help out with this as time permits - is there any interest in getting this fixed?


this is the only reason why I maintain my own fork...


Good news - 0.3.5 is going out this afternoon, and I've changed the backend to, mostly to reduce annoyance. This should resolve this issue - please reopen a new issue/pr if there are more!

@skoczen skoczen closed this

Thanks for this - works perfectly except for the return path omits the upload directory. I've issued a pull request to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @michael54
Commits on Nov 17, 2012
  1. @michael54
  2. @michael54

    improve upload dir

    michael54 authored
  3. @michael54

    Fix upload dir

    michael54 authored
Commits on Nov 23, 2012
  1. @michael54


    michael54 authored
This page is out of date. Refresh to see the latest.
10 ajaxuploader/backends/ → ajaxuploader/backends/
@@ -9,13 +9,17 @@ class EasyThumbnailUploadBackend(LocalUploadBackend):
DIMENSIONS = (100,000)
CROP = True
+ QUALITY = 100
+ DETAIL = True
+ SHARPEN = True
+ UPSCALE = True
def upload_complete(self, request, filename):
- options = {'size': self.DIMENSIONS, 'crop': self.CROP}
+ options = {'size': self.DIMENSIONS, 'crop': self.CROP, 'quality': self.QUALITY,
+ 'detail': self.DETAIL, 'sharpen': self.SHARPEN,'upscale': self.UPSCALE,}
thumb = get_thumbnailer(self._path).get_thumbnail(options)
if not self.KEEP_ORIGINAL:
- return {"path": settings.MEDIA_URL + os.path.split(thumb.path)[1]}
+ return {"path": self.UPLOAD_DIR + '/' + os.path.split(thumb.path)[1]}
3  ajaxuploader/backends/
@@ -1,6 +1,6 @@
from io import FileIO, BufferedWriter
import os
+import uuid
from django.conf import settings
from ajaxuploader.backends.base import AbstractUploadBackend
@@ -10,6 +10,7 @@ class LocalUploadBackend(AbstractUploadBackend):
UPLOAD_DIR = "uploads"
def setup(self, filename, *args, **kwargs):
+ self.UPLOAD_DIR = self.UPLOAD_DIR + "/%s" % (uuid.uuid4())
self._path = os.path.join(
settings.MEDIA_ROOT, self.UPLOAD_DIR, filename)
4 ajaxuploader/static/ajaxuploader/js/fileuploader.js
@@ -520,8 +520,8 @@ qq.FileUploader = function(o){
listElement: null,
template: '<div class="qq-uploader">' +
- '<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
- '<div class="qq-upload-button">Upload a file</div>' +
+ '<div class="qq-upload-drop-area"><span>Drop images here to upload</span></div>' +
+ '<div class="qq-upload-button">Upload an Image</div>' +
'<ul class="qq-upload-list"></ul>' +
Something went wrong with that request. Please try again.