2016-05-03 15 views
-2

すべてのcssファイルに静的ファイルリンクを追加しました。それでもブラウザにHTMLファイルのみが表示されます。 CSSファイルが機能していません。何かが間違っているかどうか教えてください。それを修正するには?CSSファイルがdjangoプロジェクトにロードされていません

私はindex.htmlページのページソースに行き、CSSリンクをクリックしました。 CSSファイルは表示されません。他のHTMLファイルを表示します。私はエラー:error page not foundを取得します。

index.htmlを

<head>{% load static %} 
    <link rel="stylesheet" href="{% get_static_prefix as STATIC_PREFIX %} /static/style1.css" type="text/css" /> 
    <title>Login Page</title> 
</head> 

<body> 
    <form action="/loginpage/" name="myForm" method="post"> 
    {% csrf_token %} 
    <fieldset> 
     <legend>Login</legend> 
     <br> 
     <p style="display:inline">Username</p> 
     <br> 
     <br> 
     <input type="text" name="user" autocomplete="off" placeholder="username" size="30" autofocus required/> 
     <br> 
     <br> 
     <p style="display:inline">Password</p> 
     <br> 
     <br> 
     <input type="password" name="pass" autocomplete="off" placeholder="password" size="30" required/> 
     <br> 
     <br> 
     <input type="submit" name="submit" value="Login" style="height:30px; width:70px" /> 
     <br> 
     <br> 
     <p style="font-family:arial; color:#FFFFFF;">{{message}}</p> 
    </fieldset> 
    </form> 
    <br> 
    <br> 
    <a href="/formlink/" id="sign">Create account</a> 
</body> 

style1.css

legend { 
    border: medium none; 
    left: 39%; 
    margin: 0 auto; 
    padding: 0 10px; 
    position: relative; 
    text-align: center; 
    width: auto; 
    color: #FFFFFF; 
    font-size: 18px; 
    font-weight: bold; 
    font: normal 130% 'century gothic', arial, sans-serif; 
} 

body { 
    background-image: url("12.jpg"); 
} 

fieldset { 
    position: absolute; 
    left: 600px; 
    top: 280px; 
    -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px; 
} 

form { 
    text-align: center; 
} 

p { 
    font: normal 100% 'century gothic', arial, sans-serif; 
    color: #FFFFFF; 
} 

#home { 
    background-color: grey; 
    color: #ffffff; 
    display: inline-block; 
    font-size: 16px; 
    margin-left: 20px; 
    opacity: 0.9; 
    padding: 14px 25px; 
    position: absolute; 
    text-decoration: none; 
    font: normal 100% 'century gothic', arial, sans-serif; 
    left: 1450px; 
    top: 100px; 
} 

#home:hover { 
    color: black; 
    text-decoration: underline; 
} 

#sign { 
    background-color: grey; 
    color: #ffffff; 
    display: inline-block; 
    font-size: 16px; 
    margin-left: 20px; 
    opacity: 0.9; 
    padding: 14px 25px; 
    position: absolute; 
    text-decoration: none; 
    font: normal 100% 'century gothic', arial, sans-serif; 
    position: absolute; 
    left: 680px; 
    top: 650px; 
} 

#sign:hover { 
    color: black; 
    text-decoration: underline; 
} 

答えて

0

あなたは試してみて、静的プレフィックスを取得し、あなたは、私が想定した内容に追加する偉大な長さに行ってきましたとにかく静的なディレクトリです、あなたはちょうどstaticタグを使用することができます

{% get_static_prefix as STATIC_PREFIX %} /static/style1.css 

を簡単にするために

{% static 'style1.css' %} 
+0

感謝:) – Rannick

+1

でなければなりませんそれは私がSTATICFILES_DIR代わりのSTATICFILES_DIRSを入れsettings.pyファイルの中だけでスペルミスです。これは間違いです。とにかくありがとう。 – Rannick

関連する問題