2016-10-30 3 views
1

heroku에 로컬로 (heroku 로컬 사용) 잘 작동하는 장고 프로젝트를 푸시하려고합니다. 나는 내 settings.py, 내가 SECRET_KEY 세트, 무작위로 django에 의해 startproject와 함께 만들었습니다. manage.py 및 wsgi.py 모두에서 heroku에 django 프로젝트를 푸시 할 때 SECRET_KEY 오류가 발생했습니다.

, 내가 가진 : 나는 실행하면 자식 푸시 Heroku가 마스터, 내가 얻을

mysite/ 
├── db.sqlite3 
├── lecture 
│   ├── admin.py 
│   ├── apps.py 
│   ├── forms.py 
│   ├── __init__.py 
│   ├── media 
│   ├── migrations 
│   │   ├── 0001_initial.py 
│   │   ├── 0002_auto_20161021_0952.py 
│   │   ├── __init__.py 
│   │   └── __pycache__ 
│   │    ├── 0001_initial.cpython-34.pyc 
│   │    ├── 0002_auto_20161021_0952.cpython-34.pyc 
│   │    └── __init__.cpython-34.pyc 
│   ├── models.py 
│   ├── __pycache__ 
│   │   ├── admin.cpython-34.pyc 
│   │   ├── apps.cpython-34.pyc 
│   │   ├── __init__.cpython-34.pyc 
│   │   ├── models.cpython-34.pyc 
│   │   ├── urls.cpython-34.pyc 
│   │   └── views.cpython-34.pyc 
│   ├── static 
│   │   └── lecture 
│   │    ├── images 
│   │    │   └── background.gif 
│   │    └── style.css 
│   ├── templates 
│   │   └── lecture 
│   │    ├── ajouter.html 
│   │    ├── base_site.html 
│   │    ├── debug.html 
│   │    ├── detail.html 
│   │    ├── detail_oeuvre.html 
│   │    ├── index.html 
│   │    ├── index_lectures.html 
│   │    └── results.html 
│   ├── tests.py 
│   ├── urls.py 
│   └── views.py 
├── log 
│   ├── admin.py 
│   ├── apps.py 
│   ├── __init__.py 
│   ├── media 
│   ├── migrations 
│   │   ├── __init__.py 
│   │   └── __pycache__ 
│   │    └── __init__.cpython-34.pyc 
│   ├── models.py 
│   ├── __pycache__ 
│   │   ├── admin.cpython-34.pyc 
│   │   ├── apps.cpython-34.pyc 
│   │   ├── __init__.cpython-34.pyc 
│   │   ├── models.cpython-34.pyc 
│   │   ├── urls.cpython-34.pyc 
│   │   └── views.cpython-34.pyc 
│   ├── templates 
│   │   └── log 
│   │    └── login_form.html 
│   ├── tests.py 
│   ├── urls.py 
│   └── views.py 
├── manage.py 
├── mysite 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── middleware.py 
│   ├── __pycache__ 
│   │   ├── __init__.cpython-34.pyc 
│   │   ├── settings.cpython-34.pyc 
│   │   ├── urls.cpython-34.pyc 
│   │   └── wsgi.cpython-34.pyc 
│   ├── settings.py 
│   ├── settings.pyc 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── wsgi.py 
│   └── wsgi.pyc 
├── polls 
│   ├── admin.py 
│   ├── admin.pyc 
│   ├── apps.py 
│   ├── apps.pyc 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── media 
│   ├── migrations 
│   │   ├── 0001_initial.py 
│   │   ├── 0001_initial.pyc 
│   │   ├── __init__.py 
│   │   ├── __init__.pyc 
│   │   └── __pycache__ 
│   │    ├── 0001_initial.cpython-34.pyc 
│   │    └── __init__.cpython-34.pyc 
│   ├── models.py 
│   ├── models.pyc 
│   ├── __pycache__ 
│   │   ├── admin.cpython-34.pyc 
│   │   ├── apps.cpython-34.pyc 
│   │   ├── __init__.cpython-34.pyc 
│   │   ├── models.cpython-34.pyc 
│   │   ├── tests.cpython-34.pyc 
│   │   ├── urls.cpython-34.pyc 
│   │   └── views.cpython-34.pyc 
│   ├── static 
│   │   └── polls 
│   │    ├── images 
│   │    │   └── background.gif 
│   │    └── style.css 
│   ├── templates 
│   │   └── polls 
│   │    ├── detail.html 
│   │    ├── index.html 
│   │    └── results.html 
│   ├── tests.py 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── views.py 
│   └── views.pyc 
├── Procfile 
├── requirements.txt 
├── templates 
│   └── admin 
│    ├── base_site.html 
│    └── index.html 

:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 

이 내 프로젝트의 arborescence입니다 부적절하게 구성됨 오류; SECRET_KEY 설정은 비워 둘 수 없습니다 :

Counting objects: 116, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (105/105), done. 
Writing objects: 100% (116/116), 1.38 MiB | 46.00 KiB/s, done. 
Total 116 (delta 13), reused 0 (delta 0) 
remote: Compressing source files... done. 
remote: Building source: 
remote: 
remote: -----> Python app detected 
remote: -----> Installing python-2.7.12 
remote:  $ pip install -r requirements.txt 
remote:  Collecting dj-database-url==0.4.1 (from -r requirements.txt (line 1)) 
remote:   Downloading dj-database-url-0.4.1.tar.gz 
remote:  Collecting Django==1.10.1 (from -r requirements.txt (line 2)) 
remote:   Downloading Django-1.10.1-py2.py3-none-any.whl (6.8MB) 
remote:  Collecting django-extensions==1.7.4 (from -r requirements.txt (line 3)) 
remote:   Downloading django_extensions-1.7.4-py2.py3-none-any.whl (200kB) 
remote:  Collecting gunicorn==19.6.0 (from -r requirements.txt (line 4)) 
remote:   Downloading gunicorn-19.6.0-py2.py3-none-any.whl (114kB) 
remote:  Collecting six==1.10.0 (from -r requirements.txt (line 5)) 
remote:   Downloading six-1.10.0-py2.py3-none-any.whl 
remote:  Collecting whitenoise==3.2.2 (from -r requirements.txt (line 6)) 
remote:   Downloading whitenoise-3.2.2-py2.py3-none-any.whl 
remote:  Installing collected packages: dj-database-url, Django, six, django-extensions, gunicorn, whitenoise 
remote:   Running setup.py install for dj-database-url: started 
remote:   Running setup.py install for dj-database-url: finished with status 'done' 
remote:  Successfully installed Django-1.10.1 dj-database-url-0.4.1 django-extensions-1.7.4 gunicorn-19.6.0 six-1.10.0 whitenoise-3.2.2 
remote: 
remote:  $ python manage.py collectstatic --noinput 
remote:  Traceback (most recent call last): 
remote:   File "manage.py", line 22, in <module> 
remote:   execute_from_command_line(sys.argv) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line 
remote:   utility.execute() 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute 
remote:   self.fetch_command(subcommand).run_from_argv(self.argv) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 196, in fetch_command 
remote:   settings.INSTALLED_APPS 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ 
remote:   self._setup(name) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup 
remote:   self._wrapped = Settings(settings_module) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__ 
remote:   mod = importlib.import_module(self.SETTINGS_MODULE) 
remote:   File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module 
remote:   __import__(name) 
remote:   File "/app/mysite/urls.py", line 20, in <module> 
remote:   url(r'^polls/', include('polls.urls')), 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include 
remote:   urlconf_module = import_module(urlconf_module) 
remote:   File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module 
remote:   __import__(name) 
remote:   File "/app/polls/urls.py", line 3, in <module> 
remote:   from . import views 
remote:   File "/app/polls/views.py", line 5, in <module> 
remote:   from .models import Choice, Question 
remote:   File "/app/polls/models.py", line 9, in <module> 
remote:   class Question(models.Model): 
remote:   File "/app/polls/models.py", line 10, in Question 
remote:   question_text = models.CharField(max_length = 200) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1043, in __init__ 
remote:   super(CharField, self).__init__(*args, **kwargs) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 166, in __init__ 
remote:   self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ 
remote:   self._setup(name) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup 
remote:   self._wrapped = Settings(settings_module) 
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 116, in __init__ 
remote:   raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") 
remote:  django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. 
remote: 
remote: !  Error while running '$ python manage.py collectstatic --noinput'. 
remote:  See traceback above for details. 
remote: 
remote:  You may need to update application code to resolve this error. 
remote:  Or, you can disable collectstatic for this application: 
remote: 
remote:   $ heroku config:set DISABLE_COLLECTSTATIC=1 
remote: 
remote:  https://devcenter.heroku.com/articles/django-assets 
remote: !  Push rejected, failed to compile Python app. 
remote: 
remote: !  Push failed 
remote: Verifying deploy.... 
remote: 
remote: ! Push rejected to lecturapp. 
remote: 
To https://git.heroku.com/lecturapp.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to 'https://git.heroku.com/lecturapp.git' 

단순히 문제를 이해할 수 없습니다. 내가 그것을 찾을 때 SECRET_KEY를 설정하지 않은 사람들의 질문이 있지만 settings.py에서 나의 것을 설정합니다.

미리 도움 주셔서 감사합니다.

편집 :

web: gunicorn mysite.wsgi --log-file - 

그리고 내 wsgi.py :

""" 
WSGI config for mysite project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ 
""" 

import os 

from django.core.wsgi import get_wsgi_application 
from whitenoise.django import DjangoWhiteNoise 

application = get_wsgi_application() 
application = DjangoWhiteNoise(application) 




os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 
+0

Procfile 및 wsgi.py를 표시하십시오. –

+0

@DanielRoseman ok done –

+0

Heroku에서 환경 변수를 설정할 수 있습니다 (탭 설정 iirc 아래). secret_key를 거기에 추가하십시오. 그러면 다음에'DISABLE_COLLECTSTATIC = 1'을 추가하십시오. 이렇게하면 문제가 해결 될 수 있습니다. – 1GDST

답변

1

당신은 (IIRC 탭 설정에 따라)에게 Heroku에서 환경 변수를 설정할 수 있습니다 여기 내 Procfile 있습니다. secret_key를 거기에 추가하십시오. 다음 번에 DISABLE_COLLECTSTATIC=1을 추가하십시오.

관련 문제