gpt4 book ai didi

django - 初始迁移时出现Django South错误

转载 作者:行者123 更新时间:2023-12-03 23:18:03 25 4
gpt4 key购买 nike

我有一个新的Django 1.3项目和应用程序。我将南方添加到settings.py且尚未运行syncdb。当我根据South教程和文档执行以下命令时,收到以下错误。


对导致问题的原因有何想法?更新:无法正确安装South(请参阅答案)。
South 0.7.3与Django 1.3兼容吗?更新:是的。


执行的命令和南错误

$ python ./manage.py schemamigration qexpenses --initial
Creating migrations directory at '/Users/matthew/development/quest-projects/qexpense-tracker/quexptrkr/../quexptrkr/qexpenses/migrations'...
Creating __init__.py in '/Users/matthew/development/quest-projects/qexpense-tracker/quexptrkr/../quexptrkr/qexpenses/migrations'...
+ Added model qexpenses.Buyer
+ Added model qexpenses.Vendor
+ Added model qexpenses.Department
+ Added model qexpenses.Project
+ Added model qexpenses.PurchaseType
+ Added model qexpenses.PurchaseOrder
Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate qexpenses
(qexpense-tracker)matthew@Matthew-Rankins-MacBook-Pro:~/development/quest-projects/qexpense-tracker/quexptrkr
$ python ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/south/migration/__init__.py", line 171, in migrate_app
applied = check_migration_histories(applied, delete_ghosts, ignore_ghosts)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/south/migration/__init__.py", line 72, in check_migration_histories
for h in histories:
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/Users/matthew/.virtualenvs/qexpense-tracker/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: south_migrationhistory
(qexpense-tracker)matthew@Matthew-Rankins-MacBook-Pro:~/development/quest-projects/qexpense-tracker/quexptrkr
$


组态

我正在运行OS X 10.6.7。以下是我的 pip 1.0virtualenv requirements.txt的输出:

$ cat requirements.txt 
Django==1.3
South==0.7.3
distribute==0.6.15
virtualenv==1.6
virtualenvwrapper==2.6.3
wsgiref==0.1.2

最佳答案

Ken Cochrane's对StackOverflow问题的答案How Come My South Migrations Doesn't Work for Django保持了关键。
对于新的Django项目和应用程序,我必须执行以下步骤:

South添加到INSTALLED_APPS中的settings.py,但不要添加您的应用
运行syncdbDjangoSouth表添加到数据库。 South修改syncdb,因此在INSTALLED_APPS中具有South很重要。
将应用添加到INSTALLED_APPS中的settings.py
为每个应用程序运行python manage.py schemamigration app_name --initial
运行python manage.py migrate app_name

阅读说明-不,所有说明
我开始使用South感到非常兴奋,以至于我跳过了installation documentation的阅读。我只是使用pip install south安装了South,然后将其添加到了我的INSTALLED_APPS中。那是我的错
Configuring Your Django Installationinstallation documentation部分指出:

加入South之后,您需要运行./manage.py syncdb制作South迁移跟踪表(出于各种原因,South不会将迁移用于其自身的模型)。

关于django - 初始迁移时出现Django South错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5687627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com