Pythonanywhere,如何使用静态文件?网址是什么?

Saa*_*lah 4 python django pythonanywhere

我是Pythonanywhere的新手,我无法弄清楚为什么静态文件没有加载...这是我存储css和图像的路径,即static/images/wikiLang.png等等

/static/admin/  /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media    
/static/        /home/saadfast/WikiWorld/static  
/media/         /home/saadfast/WikiWorld/media
Run Code Online (Sandbox Code Playgroud)

在客户端,我应该如何使用URL?

我做了什么search.html:

<div id="TopheaderImg">
  <img src="/home/saadfast/WikiWorld/static/images/wikiLogo.png" width="100px" style="float:middle"/>
  <br />
  <img src="/home/saadfast/WikiWorld/images/wikipediaLang.png" width="100px" style="float:middle"/>
</div>
Run Code Online (Sandbox Code Playgroud)

为什么图像没有加载?路径或URL应该是什么?

Gil*_*mas 6

PythonAnywhere dev在这里:我认为问题出在您在HTML中使用的路径中.映射

/static/        /home/saadfast/WikiWorld/static  
Run Code Online (Sandbox Code Playgroud)

表示/static/将在目录中查找开头的URL /home/saadfast/WikiWorld/static.这意味着你拥有的地方

<img src="/home/saadfast/WikiWorld/static/images/wikiLogo.png" width="100px" style="float:middle"/>
Run Code Online (Sandbox Code Playgroud)

你应该有

<img src="/static/images/wikiLogo.png" width="100px" style="float:middle"/>
Run Code Online (Sandbox Code Playgroud)