2017-09-27 4 views
-2

부트 스트랩이 HTML에 부딪치지 않습니다. 플랫 UI의 부트 스트랩을 사용합니다. 은 내가 <link rel="stylesheet" href="{% static './bootflat.github.io/bootflat/css/bootflat.min.css' %}"> 같은 평면 UI를 가지고 있지만 디자인이 아닌 변한 찾을 수 없습니다 http://localhost:8000/static/bootflat.github.io/bootflat/css/bootflat.min.css,but 페이지에 액세스 폴더 경로를 지정 부트 스트랩이 HTML에 맞지 않습니다.

{% load staticfiles %} 
<html lang="ja"> 
    <head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" href="{% static './bootflat.github.io/bootflat/css/bootflat.min.css' %}"> 

    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <style> 
     body { 
     padding-top: 70px; 
     } 

     .my-form { 
     width: 640px; 
     margin: 0 auto; 
     } 

     @media screen and (max-width: 768px) { 
     .my-form { 
      width: 100%; 
     } 
     } 

     .errorlist li { 
     list-style-type: none; 
     } 

     .errorlist { 
     color: red; 
     margin-left: 0; 
     padding-left: 0; 
     } 
    </style> 
    </head> 
    <body> 
    <nav class="navbar navbar-default" role="navigation"> 
     <div class="navbar-header"> 
      <p class="navbar-text">Hello</p> 
      {% if user.is_authenticated %} 
      <p class="navbar-text">{{ user.get_username }}</p> 
      {% endif %} 
     </div> 
    </nav> 

    <div class="container"> 
     {% block content %} 
     {% endblock %} 
    </div> 

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 

    <!-- Include all compiled plugins (below), or include individual files as needed --> 
    <script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script> 
    </body> 
</html> 

처럼 index.html을 썼다 (404) 신청 방법 : 요청 URL 오류가 발생합니다. 그래서 경로가 잘못되었다고 생각합니다. 디렉토리 구조는 내가이 문제를 해결하는 방법? enter image description here

index.html을이 enter image description here

내 코드에서 어떤 문제가있다 accounts.accounts 폴더 구조에있다?

+0

먼저 튜토리얼을 따르고 django 프로젝트의 구조를 배우십시오. –

답변

1

당신의 settings.py에 STATICFILES_DIRS를 포함시키지 않았다고 생각합니다. 이 줄을 settings.py에 추가하십시오. STATICFILES_DIRS는 정적 파일을 찾기 위해 디렉토리를 지정하는 데 사용됩니다

 {% static 'bootflat/css/bootflat.min.css' %} 

:

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'bootflat.github.io'), ] 

그리고에 의해 템플릿에 정적 파일에 액세스 할 수 있습니다.

하기 전에 당신은 프로젝트 구조가 어떻게 작동하는지 장고 이해할 필요가있다. 그것을 위해 몇 가지 자습서를 따르십시오.

+1

나는 먼저 그 대답을 downvoted, 당신은 장고 - 프로젝트 staructure의 작업을 통해 그를 격려 했음에 틀림 없다. 하지만 지금 내가 대답을 편집 한 후에 나는 그것을 upvoted. 네가 그걸 꺼리지 않기를 바란다. –

+0

그래, 나는 그것을 얻는다, 환호 :) –

관련 문제