首頁  >  文章  >  後端開發  >  python django 存取靜態檔案出現404或500錯誤

python django 存取靜態檔案出現404或500錯誤

高洛峰
高洛峰原創
2017-02-14 13:58:312166瀏覽

django static資料夾下面的內容方法不了出現404 500錯誤

需要查看自己的settings檔案確保有一下內容

import os
PROJECT_ROOT = os.path.dirname(__file__)

DEBUG = True

STATIC_URL = '/static/'

STATICFILES_DIRS = (

  os.path.join(PROJECT_ROOT, 'static'),
)

STATICFILES_FINDERS = (
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

<<ango,如果有一下內容

<VirtualHost *:80>
   ServerName www.mydjangosite.com
   ServerAlias mydjangosite.com
   ServerAdmin fake@mydjangosite.com

   DocumentRoot /path/to/mydjangosite
   <Directory /path/to/mydjangosite>
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       allow from all
   </Directory>

   Alias /static/ /path/to/mydjangosite/static/
   <Directory /path/to/mydjangosite/static>
       Order allow,deny
       allow from all
   </Directory>

   # The following installs the Django WSGI app
   WSGIDaemonProcess www.mydjangosite.com processes=2 threads=15 display-name=%{GROUP}
   WSGIProcessGroup www.mydjangosite.com
   WSGIScriptAlias / /path/to/mydjangosite/wsgi.py

</VirtualHost>

<ango如果有一下內容

rrreee

35ango 如果要等於True 靜態檔案才能存取?這一點不太明白

如果需要部署到web站點上需要在apache中配置靜態文件映射🎜🎜🎜rrreee🎜🎜🎜感謝閱讀,希望能幫助大家,謝謝大家對本站的支持! 🎜🎜更多python django 訪問靜態檔案出現404或500錯誤相關文章請關注PHP中文網! 🎜
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn