How to handle unmanaged models during tests

Viewed 49

In my Django project I am using 3 different databases, of which 2 are pre-populated with data (legacy databases), thus many of my models are not managed by Django managed = False. When I run tests Django throws django.db.utils.OperationalError: no such table: x.

I've been dealing with this problem for days now and already explored few Stack Overflow threads and blog articles (i.e https://medium.com/an-idea/testing-with-the-legacy-database-in-django-3be84786daba, https://hannylicious.com/blog/testing-django/, https://dev.to/vergeev/testing-against-unmanaged-models-in-django).

Sadly, nothing seems to help, some tables just don't want to be migrated to test databases (I am also using 3 test sqlite3 dbs). Many Stack Overflow threads and blog posts are old and don't apply to current Django version (3.2). I would greatly appreciate any help if anyone has experienced a similar problem and can give some advice.

0 Answers
Related