两个Django项目使用相同的数据库

时间:2016-09-20 13:43:31

标签: mysql django

我的django项目正在使用一个数据库和一个php项目。所以现在我要添加另一个将使用相同数据库的独立django项目。

设置项目后,我写了models.py,当我试图运行服务器时,它给出了错误: -

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7fcedb0338c0>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check_migrations()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 163, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 299, in build_graph
parent = self.check_key(parent, key[0])
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 160, in check_key
raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: apiapp

它不允许我运行python manage.py migrate。

如何应对此类问题。

1 个答案:

答案 0 :(得分:1)

为您制作模型并创建迁移。 在此次运行fake initial迁移

之后