def get_models(app_labels):
 from django.db.models import get_app, get_apps, get_model
 from django.db.models import get_models as get_all_models
 from django.contrib.contenttypes.models import ContentType
 EXCLUDED_MODELS = (ContentType,)
 models = []
 if (not app_labels):
  for app in get_apps():
   models += [m for m in get_all_models(app) if (m not in EXCLUDED_MODELS)]
 for app_label in app_labels:
  if ('.' in app_label):
   (app_label, model_name) = app_label.split('.', 1)
   models.append(get_model(app_label, model_name))
  else:
   models += [m for m in get_all_models(get_app(app_label)) if (m not in EXCLUDED_MODELS)]
 return models

def get_models ( app_labels ) : from django . db . models import get_app , get_apps , get_model from django . db . models import get_models as get_all_models from django . contrib . contenttypes . models import ContentType EXCLUDED_MODELS = ( ContentType , ) models = [ ] if ( not app_labels ) : for app in get_apps ( ) : models += [ m for m in get_all_models ( app ) if ( m not in EXCLUDED_MODELS ) ] for app_label in app_labels : if ( '.' in app_label ) : ( app_label , model_name ) = app_label . split ( '.' , 1 ) models . append ( get_model ( app_label , model_name ) ) else : models += [ m for m in get_all_models ( get_app ( app_label ) ) if ( m not in EXCLUDED_MODELS ) ] return models
gets a list of models for the given app labels .