如何解決django-oscar產(chǎn)品圖片無(wú)法顯示問(wèn)題,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
成都創(chuàng)新互聯(lián)公司主營(yíng)杭錦網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開(kāi)發(fā),杭錦h5微信小程序開(kāi)發(fā)搭建,杭錦網(wǎng)站營(yíng)銷(xiāo)推廣歡迎杭錦等地區(qū)企業(yè)咨詢(xún)
參考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/'
訪問(wèn)圖片的時(shí)候會(huì)報(bào)Page not found (404) 錯(cuò)誤,在 https://groups.google.com/forum/#!topic/django-oscar/CiujM572GuU 的最后找到以下答案,
修改 urls.py 文件,才可以
fromdjango.conf importsettings
fromdjango.conf.urls.static importstatic
urlpatterns =[
... # your urls setting.
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
修改后圖片可訪問(wèn)。
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
網(wǎng)頁(yè)名稱(chēng):如何解決django-oscar產(chǎn)品圖片無(wú)法顯示問(wèn)題
分享網(wǎng)址:http://www.chinadenli.net/article28/gedgjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站排名、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、全網(wǎng)營(yíng)銷(xiāo)推廣、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)