#NEWLINE# def get_models( app_labels ) : #NEWLINE# #INDENT# ' Gets a list of models for the given app labels, with some exceptions.\n        TODO: If a required model is referenced, it should also be included.\n        Or at least discovered with a get_or_create() call.\n    ' #NEWLINE# from django.db.models import get_app , get_apps , get_model #NEWLINE# from django.db.models import get_models as get_all_models #NEWLINE# EXCLUDED_MODELS = ( ContentType , ) #NEWLINE# models = [ ] #NEWLINE# if ( not app_labels ) : #NEWLINE# #INDENT# for app in get_apps ( ) : #NEWLINE# #INDENT# models += [ m for m in get_all_models ( app ) if ( m not in EXCLUDED_MODELS ) ] #NEWLINE# #UNINDENT# return models #NEWLINE# #UNINDENT# for app_label in app_labels : #NEWLINE# #INDENT# if ( '.' in app_label ) : #NEWLINE# #INDENT# ( app_label , model_name ) = app_label . split ( '.' , 1 ) #NEWLINE# models . append ( get_model ( app_label , model_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# models += [ m for m in get_all_models ( get_app ( app_label ) ) if ( m not in EXCLUDED_MODELS ) ] #NEWLINE# #UNINDENT# #UNINDENT# return models