If I call this django method, in a test, it yields a lot of models which are not installed.
These models are from other apps test code.
For example, when iI use apps.get_models() I get MROBase1 from the django package polymorphic test code.
=> I want get all models which have a table in the database. In above question I got a model which exists just for testing, which is not on the database.
NB: I use Django 1.10
You need to isolate the models from your application(s):
Create manually, a list of all your application names as strings:
my_apps=['my_app_1', 'my_app_2', ...](First Option), use
get_app_configandget_modelsmethods:You will end up with a dictionary of
'app_name': list_of_models(Second Option), use
all_models[<app_name>]attribute:You will end up with a dictionary of
'app_name': OrderedDict_of_models