2017-04-01 8 views
0

를 찾을 수없는,있는 정적 파일을로드장고 - 이물 : 정적 파일이 BowerFinder에 의해로드 할 어떤 이유

설정 (서버에서 찾을 수 없음 (404)를 받고) 할 수 있습니다 djangobower.finders.BowerFinder로드 할 수 있습니다. 평

STATIC_ROOT = "/root/Desktop/django-DefectDojo/static/" 

STATIC_URL = '/static/' 

STATICFILES_DIRS =() 

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder', 
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
    'djangobower.finders.BowerFinder', 
) 

BOWER_COMPONENTS_ROOT = '/root/Desktop/django-DefectDojo/components/' 

BOWER_INSTALLED_APPS = (
    'jquery-ui', 
) 

INSTALLED_APPS = (
    'djangobower', 
) 

템플릿

<script src="{% static "jquery-ui/jquery-ui.min.js" %}"></script> 

프로젝트 구조

-project root 
    -static 
    -components 
     -vendor 
      -assets 
       -bower-components 
        -jquery-ui 
         -jquery-ui.min.js 

내가 지금 ./manage.py collectstatic

다음에 ./manage.py bower install을, 서버를 실행에, 나는 찾을 수 없음 얻을.

그러나 STATICFILES_DIRS = ('/root/Desktop/django-DefectDojo/components/vendor/assets/bower_components/',)을 만들면 정적 파일이로드됩니다. BowerFinder이이 작업을 수행해야하므로이 경우가 아닙니다.

답변

0

일회용 인스턴스가 아닌 것으로 보입니다. 이 경우 django-bowerfinders.py은 제공된 BOWER_COMPONENTS_ROOT 변수 (bower_components 또는 components) 중 하나를 찾을 수없는 경우에 발생합니다.

-projectroot 
    -components 
     -vendors 
      -assets 
       -bower_components 
        - 
        - 

로에 대해 :

-projectroot 
    -components 
     -bower_components 
      - 
      - 

가장 쉬운 방법이 반대 BOWER_COMPONENTS_ROOT = os.path.join(PROJECT_ROOT, 'components\vendors\assets')을 설정하는 것입니다 해결하기 위해

은 다음과 같이 bower install 이제 bower_components 디렉토리를 생성하기 때문에 그렇게 할 수없는 그냥하고 BOWER_COMPONENTS_ROOT = os.path.join(PROJECT_ROOT, 'components')

관련 게시물 django-bower 님의 repo : https://github.com/nvbn/django-bower/issues/20