【问题标题】:Django reusable package - test DB is not created on the flyDjango 可重用包 - 测试数据库不是即时创建的
【发布时间】:2016-06-02 12:53:16
【问题描述】:

我正在为我的 django 可重用包/应用程序创建测试,但我的数据库不是即时创建的。

我正在 https://docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications 执行步骤

这工作正常,直到定义了一些模型,当它失败时

Creating test database for alias 'default'...
Traceback (most recent call last):
  File "c:\github.com\django\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "c:\github.com\django\django\db\backends\sqlite3\base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)sqlite3.OperationalError: no such table: table_name

文件夹中也没有sqlite3文件。

我错过了什么?

【问题讨论】:

    标签: python django django-models django-testing


    【解决方案1】:

    我发现了问题,它缺少迁移。

    创建迁移后,模型测试运行良好。

    【讨论】:

      猜你喜欢
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2020-11-17
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 2019-09-05
      相关资源
      最近更新 更多