您的媒体文件夹可能没有公共访问权限,这可能是图像未显示的原因,请将您的媒体文件夹添加到 urls.py 中的 url 模式
检查下面的示例 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'
让我知道这些更改是否适合您