Django-Oscar Images Error

Refresh

November 2018

Views

2k time

2

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

11

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

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

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

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

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

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

TEMPLATE_DIRS = (
    location('templates'),
    OSCAR_MAIN_TEMPLATE_DIR,
)
STATIC_URL = '/static/'
STATIC_ROOT = location('static')
MEDIA_URL = '/media/'
MEDIA_ROOT = location('media')
THUMBNAIL_DEBUG = True
THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'

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