Django: Get model from string?

As of Django 1.11 to 4.0 (at least), it’s AppConfig.get_model(model_name, require_ready=True)

As of Django 1.9 the method is django.apps.AppConfig.get_model(model_name).
danihp

As of Django 1.7 the django.db.models.loading is deprecated (to be removed in 1.9) in favor of the the new application loading system.
Scott Woodall


Found it. It’s defined here:

from django.db.models.loading import get_model

Defined as:

def get_model(self, app_label, model_name, seed_cache=True):

Leave a Comment