0
我正在部署一個Django應用到GitHub和Heroku。
我已經第一次部署它GitHub上,刪除(把它在的.gitignore文件)「settings.py」,而現在,我試圖把它推到Heroku的,我得到一個錯誤:Heroku推送被拒絕(Django應用)
ImportError: No module named settings
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:
remote: ! Push rejected, failed to compile Python app
我該如何避免將某些文件推送到GitHub,但同樣有可能將其推送到Heroku?
UPDATE:
我試圖保持settings.py和temp_settings.py獨立的,但現在的應用程序不工作了。這就是回溯,當我嘗試運行在本地服務器:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/stefano/projects/blog-project/blogprojectenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/stefano/projects/blog-project/blogprojectenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/home/stefano/projects/blog-project/blogprojectenv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/home/stefano/projects/blog-project/blogprojectenv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/home/stefano/projects/blog-project/blogprojectenv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/stefano/projects/blog-project/blogproject/settings.py", line 104, in <module>
DATABASES['default'].update(db_from_env)
NameError: name 'DATABASES' is not defined
看來settings.py不能「達到」 temp_settings.py,因爲我所有的數據庫設置剪切粘貼temp_settings。那是錯的嗎?
我會試試看,謝謝。 –
我試過了,當推送到GitHub時,「settings.py」上的_private_憑證位於標籤之間,如下所示:「<<<<<<< HEAD =======」但他們在那裏,我的意思是:他們不隱藏 –
這與私人憑證無關;這是git中一個糟糕的合併的結果。你需要修復它。 –