Django Easy Thumbnail not working

I am using django easy_thumbnail in a project, and I follow the instructions step by step. But I get the URL not returning.

Model containing imageField:

class Project(models.Model):
   name = models.CharField(max_length=100)
   description = models.CharField(max_length=2000)
   startDate = models.DateField(auto_now_add=True)
   photo = models.ImageField(upload_to="projectimg/", null=True, blank=True)

And in the setup, I specify:

    THUMBNAIL_ALIASES = {
    '': {
        'avatar': {'size': (50, 50), 'crop': True},
    },
    }

And I use a template filter:

<div class="image">
    <img src="{{ MEDIA_URL }}{{ project.photo|thumbnail_url:'avatar'}}" class="img-responsive" alt="{{ project.name }}">
</div>

However, the filter does not seem to return anything. Is it because the URL was not found? Or other reasons? Thank you for your time!

+3
source share
2 answers

The problem can be one of two things: either the user to whom your wsgi application is running does not have access to the directory in which the thumbnails are generated (most likely), or the pillow is incorrectly installed using the correct support.

, gunicorn, conficorn conf user = www-data, 33, , , id 33 :

chown -R 33:2000 filer_public_thumbnails

.

, Pillow .

1)

sudo pip uninstall Pillow

2) (Ubuntu)

 sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev \
 libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

(Centos)

sudo yum install python-devel
sudo yum install libjpeg-devel
#Then..
sudo yum install gcc gcc-c++ 
sudo yum install zlib-devel

sudo pip install Pillow

, .

+4

, ( OS X Mavericks 10.9.2), {{MEDIA_URL}}, , . , ( ).

: freylis .

{{ MEDIA_URL }}

.

, , .py:

THUMBNAIL_DEBUG = True

. , , , , ... , .

, , , , ( homebrew):

brew install libjpeg

, Pillow:

pip uninstall Pillow
pip install Pillow --upgrade

, "-upgrade" ( libjpeg) , , .

, , .

+2

All Articles