Pythonanywhere,如何使用静态文件?网址是什么? [英] Pythonanywhere, how to use static files? url?

查看:453
本文介绍了Pythonanywhere,如何使用静态文件?网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全不了解 Pythonanywhere ,我不知道为什么静态文件没有加载...这里是我存储css和图像的路径,
ie 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

客户端如何使用URL?



我在 search.html 中所做的一切:

 < div id =TopheaderImg> 
< img src =/ home / saadfast / WikiWorld / static / images / wikiLogo.pngwidth =100pxstyle =float:middle/>
< br />
< img src =/ home / saadfast / WikiWorld / images / wikipediaLang.pngwidth =100pxstyle =float:middle/>
< / div>

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

解决方案

PythonAnywhere dev在这里:我认为问题出在你在HTML。映射

  / static / / home / saadfast / WikiWorld / static 
pre>

表示在$ $ c $ / static / 的URL将在目录 /家/ saadfast / WikiWorld /静态。所以这意味着你有

 < img src =/ home / saadfast / WikiWorld / static / images / wikiLogo。 pngwidth =100pxstyle =float:middle/> 

您应该可以拥有

 < img src =/ static / images / wikiLogo.pngwidth =100pxstyle =float:middle/> 


I am completely new to Pythonanywhere, I cant figure out why static files are not loading... Here is the path where I stored css and images stuff, i.e. static/images/wikiLang.png etc

/static/admin/  /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media    
/static/        /home/saadfast/WikiWorld/static  
/media/         /home/saadfast/WikiWorld/media

where as in the client side how should I use the URL?

what i have done in the 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>

why the image is not loading? what should the path or URL?

解决方案

PythonAnywhere dev here: I think the problem is in the paths you're using in your HTML. The mapping

/static/        /home/saadfast/WikiWorld/static  

Means that URLs with /static/ at the start will be looked for in the directory /home/saadfast/WikiWorld/static. So that means that where you have

<img src="/home/saadfast/WikiWorld/static/images/wikiLogo.png" width="100px" style="float:middle"/>

You should probably have

<img src="/static/images/wikiLogo.png" width="100px" style="float:middle"/>

这篇关于Pythonanywhere,如何使用静态文件?网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆