Django-Oscar Images Error


November 2018


2k time


I am using Django-Oscar in Mac (mavericks). and everything looks fine but, it doesnt show any image that are correctly uploaded. in the beginning i thought that was a addressing problem but it save the pictures in the right folder. so that is not the problem. then i am trying to install libjpeg, as it was recommended in the installation tutorial.

i have uninstalled Pillow

pip uninstall pillow

and then i used this command, that i found online to install the libjpeg

brew install libjpeg 

then i installed pillow again and and then everything is the same. it is still not showing any image and the terminal shows that jpeg-8d already installed

could someone help me. thanks

1 answers


Папка СМИ не может иметь публичный доступ, который может быть причиной изображения не отображается, добавьте папку медиа в шаблон URL-адреса в

Проверьте образец ниже

from django.conf.urls import patterns, include, url
from django.contrib import admin
from import application
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
    url(r'^admin/', include(,
    url(r'^i18n/', include('django.conf.urls.i18n')),
    url(r'', include(application.urls)),
)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

А в файле, убедитесь, что вы определяете media_root и MEDIA_URL

location = lambda x: os.path.join(
os.path.dirname(os.path.realpath(__file__)), x)

STATIC_URL = '/static/'
STATIC_ROOT = location('static')
MEDIA_URL = '/media/'
MEDIA_ROOT = location('media')
THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'

Дайте мне знать, если эти изменения работают для вас