在Django部署中需要帮助

我需要有关部署django应用程序的帮助。我尝试在heroku上进行部署,但这给了我很多错误。

  

类似:SECRET_KEY不能为空(即使它不为空)

     

APP_CRASHED

我也尝试过在pythonanywhere上托管,但这也给我带来了错误。

另外,我正在使用postgres作为数据库。

我的github存储库:https://github.com/HooriaHIC/Xannys

2019-11-12T10:52:11.710011+00:00 app[web.1]: worker.init_process()
2019-11-12T10:52:11.710014+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",line 129,in init_process
2019-11-12T10:52:11.710016+00:00 app[web.1]: self.load_wsgi()
2019-11-12T10:52:11.710018+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",line 138,in load_wsgi
2019-11-12T10:52:11.710020+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-11-12T10:52:11.710026+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",line 67,in wsgi
2019-11-12T10:52:11.710028+00:00 app[web.1]: self.callable = self.load()
2019-11-12T10:52:11.710030+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",line 52,in load
2019-11-12T10:52:11.710032+00:00 app[web.1]: return self.load_wsgiapp()
2019-11-12T10:52:11.710034+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",line 41,in load_wsgiapp
2019-11-12T10:52:11.710036+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-11-12T10:52:11.710038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",line 350,in import_app
2019-11-12T10:52:11.710040+00:00 app[web.1]: __import__(module)
2019-11-12T10:52:11.710046+00:00 app[web.1]: File "/app/djecommerce/wsgi.py",line 5,in <module>
2019-11-12T10:52:11.710048+00:00 app[web.1]: application = get_wsgi_application()
2019-11-12T10:52:11.710050+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py",line 12,in get_wsgi_application
2019-11-12T10:52:11.710052+00:00 app[web.1]: django.setup(set_prefix=False)
2019-11-12T10:52:11.710054+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py",line 19,in setup
2019-11-12T10:52:11.710056+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG,settings.LOGGING)
2019-11-12T10:52:11.710058+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",line 79,in __getattr__
2019-11-12T10:52:11.710060+00:00 app[web.1]: self._setup(name)
2019-11-12T10:52:11.710062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",line 66,in _setup
2019-11-12T10:52:11.710063+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2019-11-12T10:52:11.710065+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",line 176,in __init__
2019-11-12T10:52:11.710068+00:00 app[web.1]: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2019-11-12T10:52:11.710114+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2019-11-12T10:52:11.710770+00:00 app[web.1]: [2019-11-12 10:52:11 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-11-12T10:52:11.833938+00:00 app[web.1]: [2019-11-12 10:52:11 +0000] [11] [ERROR] Exception in worker process
2019-11-12T10:52:11.833943+00:00 app[web.1]: Traceback (most recent call last):
2019-11-12T10:52:11.833945+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 583,in spawn_worker
2019-11-12T10:52:11.833948+00:00 app[web.1]: worker.init_process()
2019-11-12T10:52:11.833950+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",in init_process
2019-11-12T10:52:11.833952+00:00 app[web.1]: self.load_wsgi()
2019-11-12T10:52:11.833954+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",in load_wsgi
2019-11-12T10:52:11.833956+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-11-12T10:52:11.833959+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",in wsgi
2019-11-12T10:52:11.833961+00:00 app[web.1]: self.callable = self.load()
2019-11-12T10:52:11.833963+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load
2019-11-12T10:52:11.833965+00:00 app[web.1]: return self.load_wsgiapp()
2019-11-12T10:52:11.833967+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load_wsgiapp
2019-11-12T10:52:11.833969+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-11-12T10:52:11.833971+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",in import_app
2019-11-12T10:52:11.833974+00:00 app[web.1]: __import__(module)
2019-11-12T10:52:11.833976+00:00 app[web.1]: File "/app/djecommerce/wsgi.py",in <module>
2019-11-12T10:52:11.833978+00:00 app[web.1]: application = get_wsgi_application()
2019-11-12T10:52:11.833981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py",in get_wsgi_application
2019-11-12T10:52:11.833983+00:00 app[web.1]: django.setup(set_prefix=False)
2019-11-12T10:52:11.833985+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py",in setup
2019-11-12T10:52:11.833988+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG,settings.LOGGING)
2019-11-12T10:52:11.833990+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",in __getattr__
2019-11-12T10:52:11.833991+00:00 app[web.1]: self._setup(name)
2019-11-12T10:52:11.833993+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",in _setup
2019-11-12T10:52:11.833995+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2019-11-12T10:52:11.833997+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py",in __init__
2019-11-12T10:52:11.833999+00:00 app[web.1]: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2019-11-12T10:52:11.834005+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2019-11-12T10:52:11.834714+00:00 app[web.1]: [2019-11-12 10:52:11 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-11-12T10:52:11.880751+00:00 app[web.1]: Traceback (most recent call last):
2019-11-12T10:52:11.880758+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 210,in run
2019-11-12T10:52:11.881198+00:00 app[web.1]: self.sleep()
2019-11-12T10:52:11.881203+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 360,in sleep
2019-11-12T10:52:11.881565+00:00 app[web.1]: ready = select.select([self.PIPE[0]],[],1.0)
2019-11-12T10:52:11.881569+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 245,in handle_chld
2019-11-12T10:52:11.881848+00:00 app[web.1]: self.reap_workers()
2019-11-12T10:52:11.881852+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 525,in reap_workers
2019-11-12T10:52:11.882283+00:00 app[web.1]: raise HaltServer(reason,self.WORKER_BOOT_ERROR)
2019-11-12T10:52:11.882341+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2019-11-12T10:52:11.882344+00:00 app[web.1]:
2019-11-12T10:52:11.882346+00:00 app[web.1]: During handling of the above exception,another exception occurred:
2019-11-12T10:52:11.882348+00:00 app[web.1]:
2019-11-12T10:52:11.882353+00:00 app[web.1]: Traceback (most recent call last):
2019-11-12T10:52:11.882357+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn",line 11,in <module>
2019-11-12T10:52:11.882580+00:00 app[web.1]: sys.exit(run())
2019-11-12T10:52:11.882582+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",line 61,in run
2019-11-12T10:52:11.882755+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2019-11-12T10:52:11.882759+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",line 223,in run
2019-11-12T10:52:11.883018+00:00 app[web.1]: super(Application,self).run()
2019-11-12T10:52:11.883022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",line 72,in run
2019-11-12T10:52:11.883198+00:00 app[web.1]: Arbiter(self).run()
2019-11-12T10:52:11.883202+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 232,in run
2019-11-12T10:52:11.883457+00:00 app[web.1]: self.halt(reason=inst.reason,exit_status=inst.exit_status)
2019-11-12T10:52:11.883461+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 345,in halt
2019-11-12T10:52:11.883815+00:00 app[web.1]: self.stop()
2019-11-12T10:52:11.883840+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 393,in stop
2019-11-12T10:52:11.884179+00:00 app[web.1]: time.sleep(0.1)
2019-11-12T10:52:11.884183+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",in handle_chld
2019-11-12T10:52:11.884446+00:00 app[web.1]: self.reap_workers()
2019-11-12T10:52:11.884449+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",in reap_workers
2019-11-12T10:52:11.884881+00:00 app[web.1]: raise HaltServer(reason,self.WORKER_BOOT_ERROR)
2019-11-12T10:52:11.884907+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2019-11-12T10:52:12.019473+00:00 heroku[web.1]: State changed from up to crashed
2019-11-12T10:52:12.004142+00:00 heroku[web.1]: Process exited with status 1
2019-11-12T10:52:22.743225+00:00 app[api]: Starting process with command `python manage.py migrate` by user hooria.hic@gmail.com
2019-11-12T10:52:33.963000+00:00 heroku[run.2955]: State changed from starting to up
2019-11-12T10:52:33.936796+00:00 heroku[run.2955]: Awaiting client
2019-11-12T10:52:34.007350+00:00 heroku[run.2955]: Starting process with command `python manage.py migrate`
2019-11-12T10:52:46.514812+00:00 heroku[run.2955]: State changed from up to complete
2019-11-12T10:52:46.502306+00:00 heroku[run.2955]: Process exited with status 0
2019-11-12T10:53:04.809501+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-basin-29081.herokuapp.com request_id=a0609543-47a1-4f49-86db-faac1762ab33 fwd="196.194.23.86" dyno= connect= service= status=503 bytes= protocol=https
2019-11-12T10:53:05.348482+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-basin-29081.herokuapp.com request_id=4eed1f99-b1dc-4db9-847a-ed831f3a8108 fwd="196.194.23.86" dyno= connect= service= status=503 bytes= protocol=https

谢谢。

langku 回答:在Django部署中需要帮助

问题是您共享3个文件中的设置,但是忘记在wsgi.py文件中设置设置模块。

尝试编辑此os.environ.setdefault('DJANGO_SETTINGS_MODULE','djecommerce.settings')os.environ.setdefault('DJANGO_SETTINGS_MODULE','djecommerce.settings.production')

本文链接:https://www.f2er.com/3117984.html

大家都在问