我刚刚开始在现有应用程序中使用南,在将新模型添加到数据库后,我可以在管理员中查看模型,但是当单击它们查看模型详细信息时出现错误
我尝试做相当于syncdb的南方:
python manage.py schemamigration directory --initial
python manage.py migrate directory
其中目录是应用程序名称。
因此,当我尝试在管理员中查看模型时,我得到以下信息:
Exception Type: DatabaseError
Exception Value: (1146, "Table 'omada.directory_drift' doesn't exist")
其中 Drift 是我添加到 models.py 中的模型,然后在 admin.py 中注册 - omada 是站点名称。
更多信息:
来自 django 站点的回溯以:
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py" in execute
114. return self.cursor.execute(query, args) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b5-py2.7-linux-i686.egg/MySQLdb/cursors.py" in execute
201. self.errorhandler(self, exc, value) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b5-py2.7-linux-i686.egg/MySQLdb/connections.py" in defaulterrorhandler
36. raise errorclass, errorvalue
执行时
python manage.py migrate directory
我收到一个错误,开头是:
FATAL ERROR - The following SQL query failed: CREATE TABLE `directory_building`
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
这听起来不太有希望:S,并以:
File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b5-py2.7-linux-i686.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.DatabaseError: (1050, "Table 'directory_building' already exists")
提前感谢所有花时间阅读本文并提供帮助的人!