<p><span style="font-family:Microsoft YaHei; font-size:18px"><span style="white-space:pre"></span>最近在写几个网页,之前的配置文件都是抄别人的 ,于是在自己开始一个新的项目时,被那些文件路径给折腾得死去活来,今天照着一片文章总算是把路径给配好了。同时也萌生了开一个博客,记录自己这个代码菜鸟的漫漫长路。以后遇到类似问题也不用再那么纠结了。</span></p>
<p><span style="font-family:Microsoft YaHei; font-size:18px"><br> </span></p>
<p><span style="font-family:Microsoft YaHei; font-size:18px"><span style="white-space:pre"></span>遇到的问题:加载不了项目中的静态文件。</span></p>
<p><span style="font-family:Microsoft YaHei; font-size:18px">当前项目的目录结构:</span></p>
<p><span style="white-space:pre"><span style="font-family:Microsoft YaHei; font-size:18px"><img alt="" src=""></span></span></p>
<p><span style="font-family:Microsoft YaHei; font-size:18px"><span style="white-space:pre">其中</span>,html文件放在templates文件夹下,css,js,和网页用到的图片都放在static文件夹下。</span></p>
<p><br> </p>
<p><span style="line-height:26px; font-family:'Microsoft YaHei'; font-size:18px">具体步骤为:<br> 1. 在settings.py中添加与修改:</span></p>
<p></p>
<div class="dp-highlighter bg_python" style="font-family:Consolas,'Courier New',Courier,mono,serif; width:936.53125px; overflow:auto; padding-top:1px; line-height:26px; margin:18px 0px!important; background-color:rgb(231,229,220)">
<div class="bar" style="padding-left:45px">
<div class="tools" style="padding:3px 8px 10px 10px; font-size:9px; line-height:normal; font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; color:silver; border-left-width:3px; border-left-style:solid; border-left-color:rgb(108,226,108); background-color:rgb(248,248,248)">
<strong>[python]</strong>
<a class="ViewSource" href="http://blog.csdn.net/pleasecallmewhy/article/details/8936390#" rel="noopener noreferrer" style="color:rgb(160,160,160); text-decoration:none; border:none; padding:1px; margin:0px 10px 0px 0px; font-size:9px; display:inline-block; width:16px; height:16px; text-indent:-2000px; background-color:inherit" target="_blank" title="view plain">view plain</a>
<a class="CopyToClipboard" href="http://blog.csdn.net/pleasecallmewhy/article/details/8936390#" rel="noopener noreferrer" style="color:rgb(160,160,160); text-decoration:none; border:none; padding:1px; margin:0px 10px 0px 0px; font-size:9px; display:inline-block; width:16px; height:16px; text-indent:-2000px; background-color:inherit" target="_blank" title="copy">copy</a>
<div style="position:absolute; left:492px; top:515px; width:18px; height:18px; z-index:99">
</div>
</div>
</div>
<ol class="dp-py" start="1" style="padding:0px; border:none; list-style-position:initial; color:rgb(92,92,92); margin:0px 0px 1px 45px!important; background-color:rgb(255,255,255)"><li class="alt" style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit"><span class="comment" style="margin:0px; padding:0px; border:none; color:rgb(0,130,0); background-color:inherit"># static/file operation</span><span style="margin:0px; padding:0px; border:none; background-color:inherit"> </span></span></li><li style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important; background-color:rgb(248,248,248)"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit">PROJECT_PATH = os.path.dirname(os.path.dirname(__file__)) </span></li><li class="alt" style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit"> </span></li><li style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important; background-color:rgb(248,248,248)"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit"><span class="comment" style="margin:0px; padding:0px; border:none; color:rgb(0,130,0); background-color:inherit"># Absolute filesystem path to the directory that will hold user-uploaded files.</span><span style="margin:0px; padding:0px; border:none; background-color:inherit"> </span></span></li><li class="alt" style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> <span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit"><span class="comment" style="margin:0px; padding:0px; border:none; color:rgb(0,130,0); backgrou |
|