Search code examples
pythonmysqldjangopycharmmysql-connector-python

Wrong table used when running tests Django Pycharm


I used inspectdb to import the Models schema from MySQL database connected with MySQL Connector/Python.

When I run the tests, the system shows:

django.db.utils.ProgrammingError: Table 'test_mydb.cards' doesn't exist

But the table name is just mydb.cards, not test_mydb.cards

Why is this prefix being added? My app's name is just container.


Solution

  • I found the reason: I had managed property to False in models.py Class Meta for each table. I never set it there myself, it is the default after doing inspectdb.

    Please read: Django Models Options: Managed