我正在嘗試訪問django-import-export-celery模塊中使用的這些檔案:

我能夠在本地看到我的觀點:

但它沒有顯示在我的生產服務器上:

這是我的urlpattern:
urlpatterns = static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
) [
# favicon
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('img/Dalmore-Group-16-16.png'))),
# debug
path('__debug__/', include(debug_toolbar.urls)),
url(r'^', admin.site.urls),
]
我settings.py有:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
更新:
我在日志中收到此錯誤:
tail /var/log/gunicorn.err.log
WARNING:django.request:Not Found: /media/django-import-export-celery-import-change-summaries/new1_1_1hRlmBz_ubIptVv_St8xqbE_1_z2_PGH9e4O.html
即使它存在:
ls -A media/django-import-export-celery-import-change-summaries/
new1_1_1hRlmBz_ubIptVv_St8xqbE_1_z2_PGH9e4O.html

uj5u.com熱心網友回復:
我加了這個:
location /media/ {
root /home/ubuntu/dalmoreportal;
}
在 /etc/nginx/sites-available/django.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/386048.html
