Search code examples
pythondjangodjango-modelsdjango-testing

Django reusable package - test DB is not created on the fly


I'm creating tests for my django reusable package/application and my DB is not being created on the fly.

I'm following steps at https://docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications

This works fine until there is some model defined, when it fails on

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

There is no sqlite3 file in folder created neither.

What am I missing?


Solution

  • I've found out the problem, it was missing migrations.

    Once migrations has been created, tests with models are running just fine.