2017-10-22 1 views
0

정적 파일을 찾을은`t 내가 내 오랜 장고 프로젝트를 수정 한내가 맥 OS 시에라가 장고

내가 폴더 static 및 폴더가 (프로젝트가 리눅스 시스템에서 만든, 어쩌면이 몇 가지 버그를 호출) 내가 서버를 실행할 때 static

내부 landing 그리고,이 출력됩니다 :이 변수 정적 내 settings 파일 GET /static/landing/img/397x300/03.jpg HTTP/1.1" 404 1691

입니다 -

STATIC_DIR = os.path.join(BASE_DIR, 'static') 
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'), 
    '/Users/milkiweed/Documents/python/django/psy_site/static' 

UPD. 내가 python3 manage.py collectstatic를 사용하려고 할 때 내가 다음 문제가 : 개발에

You have requested to collect static files at the destination 
location as specified in your settings. 

This will overwrite existing files! 
Are you sure you want to do this? 

Type 'yes' to continue, or 'no' to cancel: yes 
Traceback (most recent call last): 
    File "manage.py", line 22, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/core/management/__init__.py", line 364, in  execute_from_command_line 
    utility.execute() 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/core/management/__init__.py", line 356, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/core/management/base.py", line 283, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/core/management/base.py", line 330, in execute 
    output = self.handle(*args, **options) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/contrib/staticfiles/management/commands/collectstatic.py" , line 199,in handle 
    collected = self.collect() 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/contrib/staticfiles/management/commands/collectstatic.py" , line 124,in collect 
    handler(path, prefixed_path, storage) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/contrib/staticfiles/management/commands/collectstatic.py" , line 354,in copy_file 
    if not self.delete_file(path, prefixed_path, source_storage): 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/contrib/staticfiles/management/commands/collectstatic.py" , line 260,in delete_file 
    if self.storage.exists(prefixed_path): 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/core/files/storage.py", line 392, in exists 
    return os.path.exists(self.path(name)) 
    File "/Users/milkiweed/Documents/vn/psychology/lib/python3.6/site- packages/django/contrib/staticfiles/storage.py", line 50, in path 
    raise ImproperlyConfigured("You're using the staticfiles app " 
django.core.exceptions.ImproperlyConfigured: You're using the  staticfiles app without having set the STATIC_ROOT setting to a  filesystem path. 
+0

장고 버전? collectstatic 실행 했습니까? (https://docs.djangoproject.com/en/1.11/howto/static-files/ 참조) – Davy

+0

@Davy 버전 (1, 11, 6, 'final', 0)을 사용합니다. 이제 collectstatic을 사용하려고합니다 –

+0

STATIC_ROOT가 설정되어 있습니까? – Davy

답변

0

을 (DEBUG=True) 환경, 당신은 settings.py에 두 가지가 필요합니다

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

이 충분해야한다고, 당신의 static 디렉토리를 가정 최상위 수준 인 BASE_DIR에 있습니다. static 디렉토리가 다른 곳에 있으면 STATICFILES_DIRS을 적절하게 조정하십시오.