Q:

Django - How to use getattr for Dynamic Model?

Django - How to use getattr for Dynamic Model.
I cannot make this work.
_tipo = getattr(Model(), request.GET.get('modelName'))('objects')
        print(_tipo.all())

A:

you can use this get_model method to obtain a model. Then you can use getattr method for objects.
from django.apps import apps
Model = apps.get_model('app_label', request.GET.get('modelName'))
_tipo = getattr(Model, 'objects')
print(_tipo.all())

