简体   繁体   中英

Django-Oscar Images Error

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

Your media folder may not have public access which could be the reason for image not showing up, add your media folder to the url pattern in urls.py

Check the sample urls.py below

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)

And in your settings.py file, make sure you define media_root and 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'

Let me know if these changes work for you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM