2017-03-29 1 views
0

장고 1.10 + uWsgi + nginx를 사용하고 있습니다.Django - 정적/CACHE 파일을 찾을 수 없습니다.

404 ... static/CACHE/js/e3a6fa7588d1.js" failed (2: No such file or directory), 

폴더 static/CACHE는 (그래서 404의 메이크업 감각) 비어, 그런데 왜 : 정적 파일이 표시되지 않습니다 생산성 모드에서 이 내의 nginx 오류 로그가 나에게 말한다 무엇인가? static/CACHE에 대한 사용 권한을 이미 775 (으)로 설정했습니다.

의 nginx의 conf :

# /etc/nginx/sites/available/mysite_nginx.conf 
# the upstream component nginx needs to connect to 
upstream bdjango { 
    server unix:///tmp/mysite.sock; # for a file socket 
} 
# configuration of the server 
server { 
    # the port your site will be served on 
    listen 80; 

    # the domain name it will serve for 
    server_name dev.mysite.com; # substitute your machine's IP address or FQDN 
    charset utf-8; 

    # max upload size 
    client_max_body_size 8M; # adjust to taste 

    # Django media 
    location /media { 
     alias /var/www/mysite/src/media; # your Django project's media files - amend as required 
    } 
    location /static { 
     alias /var/www/mysite/src/static; # your Django project's static files - amend as required 
    } 
    # Finally, send all non-media requests to the Django server. 
    location/{ 
     uwsgi_pass adjango; 
     include /var/www/mysite/src/uwsgi_params; # the uwsgi_params file you installed 
    } 
} 

장고 설정은 그래서

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + "../../../") 
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') 

를 포함, 왜 내 JS/CSS를 static/CACHE에없는 파일입니까?

는 편집 : 는 그것을 해결 : uwsgi_pass는 (다른 웹 사이트를 우연히) 잘못된 상류 위치에서 가리키고 : uwsgi_pass adjango;

답변

1

그것은 django-compressor가 실패 일 수 있었다.

설정에 DEBUG = TrueCOMPRESS_ENABLED = True이 표시되고 작동하는지 확인해 보셨습니까?

https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED

또한, 나는 생산 ADMINS 설정 때문에 이메일 당신에게 어떤 오류 또는 제작 설정에서 설정 sentry을 가지는 것이 좋습니다.

+0

이미 있습니다. 파일은'/ static'에 복사되지만,'static/CACHE' 파일은 비어 있습니다. – FeedTheWeb

+0

'장고 압축기'입니까? – user73657

+0

예. 하지만 파일을 만드는 것 같지 않습니다. – FeedTheWeb

1
  1. 캐시를 사용하고 있습니까?
  2. STATIC_URL 및 STATIC_ROOT을 올바르게 방어 한 적이 있습니까?
  3. DEBUG = False입니까?
  4. 타사 도구를 사용하여 정적 파일을 캐시/pipline 하시겠습니까?