1

when i upload image on django filer, that image is in media directory, but i get file missing message on admin..

Image:

enter image description here

settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'myproject/static/')
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'myproject/public'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'myproject/media/')
MEDIA_URL = '/media/'

urls.py:

...
if settings.DEBUG:
    # static files (images, css, javascript, etc.)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

How can i fix this?

Mirza Delic
  • 4,119
  • 12
  • 55
  • 86

1 Answers1

4

Edit Check to see that PIL/Pillow is properly installed as a dependency of easy_thumbnails. Usually, a missing decoder, e.g. libjpeg, would cause this behavior.

On 64-bit Ubuntu, you can do the following:

pip uninstall PIL
sudo apt-get install libjpeg8
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
pip install PIL

For Macintosh,

pip uninstall PIL
brew install libjpeg
pip install PIL

Original but incorrect In urls.py, try this:

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

if settings.DEBUG:
    urlpatterns = patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    ) + staticfiles_urlpatterns() + urlpatterns

Also, check if the files are uploaded to the right directory.

mrkre
  • 1,548
  • 15
  • 43
  • Tried with this, but still nothing.. images are uploaded to media dir, and images exist there.. – Mirza Delic Aug 20 '14 at 11:30
  • 1
    Which version of django-filer are you using? Try adding `FILER_DEBUG=True` in your settings file to investigate further. It could also be due to a missing thumbnail - in admin_file.html, this error appears if object.icons.32 is not found. You could also check your easy_thumbnail installation. Sometimes it's due to an incomplete Pillow/PIL installation (missing JPG decoder). – mrkre Aug 20 '14 at 16:26
  • You're right `decoder jpeg not available`, but i reinstalled pillow and easy-thumbnails, but still same :/ – Mirza Delic Aug 20 '14 at 22:59
  • 1
    You need to install `libjpeg` refer to this answer http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil – mrkre Aug 21 '14 at 07:21