나는 heroku에 익숙하지 않고 css없이 간단한 django app를 시도했다.Django heroku static dir
하지만 난 그냥 내 애플 리케이션에 CSS 파일을 추가하고 내가이 작업을 수행 할 때
는git push heroku master
정적 파일 컬렉션 실패
: 여기[...]
-----> Collecting static files
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
collected = self.collect()
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 104, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 105, in list
for path in utils.get_files(storage, ignore_patterns):
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 25, in get_files
directories, files = storage.listdir(location)
File "/tmp/build_2unndirli15s7/.heroku/venv/lib/python2.7/site-packages/django/core/files/storage.py", line 235, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/home/kevin/web/django/appheroku/blogapp/static'
! Heroku push rejected, failed to compile Python/django app
To [email protected]:[...]
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:[...]'
내 settings.py입니다
[...]
STATIC_ROOT = '/home/kevin/web/django/appheroku/staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'/home/kevin/web/django/appheroku/blogapp/static',
)
[...]
The urls.py :
01 2,362,Procfile :
그것은 디렉토리 존재조차 '/ appheroku/blogapp/정적/홈/케빈/웹/장고'가 감지되지 보인다web: python appheroku/manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT appheroku/monblog/settings.py
나는 이유를 알아낼 수 없습니다.
지금 내 settings.py는 다음과 같습니다 :
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_DIR = os.path.join(PROJECT_ROOT,'../blogapp')
[...]
STATIC_ROOT = os.path.join(PROJECT_ROOT,'staticfiles/')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR,'static/'),
)
[...]
그리고 이제 정적 파일 수집 단계는 잘 작동하는 것 같다을 :
:(는
편집 ^^ 제발 도와주세요
-----> Collecting static files
74 static files copied.
내 문제가 있습니다 : 내 procfile에 , 'appherok u/manage.py ','bin/gunicorn_django '및'appheroku/monblog/settings.py '을 찾을 수 없습니다. 나는 그것을 고정 이제 내 procfile은 다음과 같습니다
web: python manage.py collectstatic --noinput; gunicorn_django --workers=4 --bind=0.0.0.0:$PORT monblog.settings
이 앱은 더 이상 충돌하지 않습니다하지만 CSS는 아직 없다. 여기 로그입니다 :
'2012-05-31T17:35:16+00:00 heroku[router]: GET xxxx-xxxx-number.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=85ms status=200 bytes=1054
2012-05-31T17:35:17+00:00 heroku[router]: GET xxxx-xxxx-number.herokuapp.com/static/css/style.css dyno=web.1 queue=0 wait=0ms service=5ms status=404 bytes=2088
2012-05-31T17:35:17+00:00 heroku[router]: GET xxxx-xxxx-number.herokuapp.com/static/js/jquery-1.7.2.min.js dyno=web.1 queue=0 wait=0ms service=5ms status=404 bytes=2115'
EDIT3 :
예! 그것은 작동합니다 ^^ 문제는 내 urls.py에있었습니다. 내가 쓴 :
[...]
if not settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
대신
[...]
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
가 오류가 내 메시지에 .. 그래, 나를 도와 정말 어려웠다되지 않았습니다. (미안) 너무 어리 석다. ^^ '
이제이 편집 방법에서 설명한대로 일부 수정 사항을 사용하여이 접근법을 사용합니다. 내 정적 디렉토리 ('static /')가 내 app 디렉토리 ('blogapp /') 안에 있기 때문에. 내 문제를 해결한다. (심지어 지금은 다른 것을 가지고있다.) – heathen90
'blogapp /'는이 설정 파일의 상위 디렉토리에 있는가? 'blogapp '는 설정 파일과 같은 디렉토리에있을 가능성이 높습니다. 즉,'../ blogapp' 대신'blogapp /'에 합류해야합니다. –
appheroku /는 monblog/디렉토리의 blogapp/디렉토리와 staticfiles 디렉토리가 포함되어 있습니다. blogapp/디렉토리에는 models.py 파일, views.py 파일, admin.py, .. (etc) 및 정적/디렉토리가 들어 있습니다. monblog/디렉토리에는 settings.py, urls.py 등이 있습니다. – heathen90