2015-04-19 195 views
8

我想部署一個Django(1.8)應用程序Heroku,運行時Python 3.4.2。該應用程序成功地運行(除未創建表的事實),但是當試圖運行執行syncdb我得到以下錯誤:Django遷移失敗heroku

Running `python manage.py syncdb` attached to terminal... up, run.5851 
/app/.heroku/python/lib/python3.4/site-packages/django/core/management  
/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command 
will be removed in Django 1.9 
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) 

Traceback (most recent call last): 
File "/app/.heroku/python/lib/python3.4/site-packages/django/db/migrations/loader.py", line 157, in check_key 
return list(self.graph.root_nodes(key[0]))[0] 
IndexError: list index out of range 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "manage.py", line 10, in <module> 
execute_from_command_line(sys.argv) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
utility.execute() 
File "/app/.heroku/python/lib/python3.4/site-packages/django /core/management/__init__.py", line 330, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv 
self.execute(*args, **cmd_options) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute 
output = self.handle(*args, **options) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/commands/syncdb.py", line 25, in handle 
call_command("migrate", **options) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 120, in call_command 
return command.execute(*args, **defaults) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute 
output = self.handle(*args, **options) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 93, in handle 
executor = MigrationExecutor(connection, self.migration_progress_callback) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/db/migrations/executor.py", line 19, in __init__ 
self.loader = MigrationLoader(self.connection) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/db/migrations/loader.py", line 47, in __init__ 
self.build_graph() 
File "/app/.heroku/python/lib/python3.4/site-packages/django/db/migrations/loader.py", line 287, in build_graph 
parent = self.check_key(parent, key[0]) 
File "/app/.heroku/python/lib/python3.4/site-packages/django/db/migrations/loader.py", line 164, in check_key 
raise ValueError("Dependency on app with no migrations: %s" % key[0]) 
ValueError: Dependency on app with no migrations: authentication 

我使用SQLite。

+0

在你安裝的應用程序'authentication'? – knbk

+0

是的,身份驗證在已安裝的應用程序中。 – user3706162

回答

8

在您的開發機器上,使用python manage.py makemigrations創建您的遷移。然後,假設您的遷移文件夾被推送到heroku,在heroku上運行python manage.py migrate而不是python manage.py syncdb。請參閱docs

+0

我遇到同樣的問題。我如何處理我虛擬環境中的django應用程序的遷移?也許這不是我的問題,我不確定。 – northben

+2

嘗試heroku運行python manage.py migrate。這將遷移生產機器虛擬環境中的應用程序。 – mcastle

2

我,我用我們在我們的前綴「的Heroku運行」這就是它的本地服務器使用相同的命令來解決這個問題..

的如: -

python manage.py makemigrations 

它將工作在我們當地但是Heroku的,像這樣的: -

heroku run python manage.py makemigrations 
2

我哈德進入Heroku的機器慶典

heroku run bash

然後進行makemigrations

heroku run python manage.py makemigrations 

最後,

heroku run python manage.py migrate