2017-02-22 1 views
1

저는 장고 프레임 워크를 사용하는 웹 사이트에서 작업하고 있습니다. 내 프로젝트와 관련된 정적 파일을 our_static 폴더와 collectstatic 파일을 static에 넣었습니다. Django 정적 파일을 찾을 수 없습니다.

{% load staticfiles %}  
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="{% static 'style.css' %}" /> 
</head> 

여기 our_static 파일에서 모든 읽기 점점되지 않습니다 아래 내 설정은

STATIC_URL = '/static/' 
STATIC_ROOT = os.path.join(BASE_DIR, "static/") 

STATICFILES_DIRS = [ 
    os.path.join(BASE_DIR, "our_static"), 
] 

base.html 파일입니다. 내 style.cssour_static 폴더에 있습니다.

EDIT : 내 서버로 AWS EC2 우분투 14.04를 사용하고 있습니다.이 웹 사이트는 AWS 우분투 서버가 아닌 로컬 호스트에서 제대로 작동합니다. Apache2 서버를 사용하고 있습니다.

더 많은 설정 :

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
STATICFILES_FINDERS =[ 
'django.contrib.staticfiles.finders.FileSystemFinder', 
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
] 

내 아파치 설정 :

Alias /static /home/ubuntu/pythonserver/static 
<Directory /home/ubuntu/pythonserver/static> 
    Require all granted 
</Directory> 

<Directory /home/ubuntu/pythonserver/pythonserver> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
</Directory> 

WSGIDaemonProcess pythonserver python-path=/home/ubuntu/pythonserver python-home=/home/ubuntu/knowmenow/ 
WSGIProcessGroup pythonserver 
WSGIScriptAlias//home/ubuntu/pythonserver/pythonserver/wsgi.py 
+0

입니까? 'BASE_DIR' 설정을 추가하십시오. 서버에서 해당 구성이 무엇입니까? 두 경우 모두 렌더링 된 html로 표시되는 내용은 무엇입니까? 'href = "{% static 'style.css'%}"'? – YPCrumble

+0

로컬 서버에서 제대로 작동합니다. 문제는 내가 aws 서버 (우분투)에 배포 할 때입니다. 'BASE_DIR = os.path.dirname (os.path.dirname (os.path.abspath (__ file__))) '는 내 'BASE_DIR'입니다. – Naroju

+0

어떤 웹 서버를 사용하고 있습니까 (예 : NGINX, Apache?)? 구성을 제공하십시오. 사이트의 렌더링 된 html을 검사 할 때'href = "{% static 'style.css'%}"'는 브라우저의 html처럼 표시됩니까? – YPCrumble

답변

관련 문제