如何解决django-oscar产品图片无法显示问题,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
参考demo中的 setting.py 配置了
# Path helper
location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)# Absolute path to the directory that holds media.
# Example: "/home/media/media.laWrence.com/"
MEDIA_ROOT = location("public/media")# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.laWrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
访问图片的时候会报Page not found (404) 错误,在 https://groups.google.com/forum/#!topic/django-oscar/CiujM572GuU 的最后找到以下答案,
from django.conf import settings
from django.conf.urls.static import static
urlpatterns =[
... # your urls setting.
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注编程之家行业资讯频道,感谢您对编程之家的支持。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。