def ensure_completely_loaded(force=False):
 global COMPLETELY_LOADED
 if (COMPLETELY_LOADED and (not force)):
  return True
 from django.apps import apps
 if (not apps.ready):
  return
 import django
 from distutils.version import LooseVersion
 if (LooseVersion(django.get_version()) < LooseVersion(u'1.8')):
  for model in apps.get_models():
   for cache_name in (u'_field_cache', u'_field_name_cache', u'_m2m_cache', u'_related_objects_cache', u'_related_many_to_many_cache', u'_name_map'):
    try:
     delattr(model._meta, cache_name)
    except AttributeError:
     pass
   model._meta._fill_fields_cache()
  if hasattr(apps, u'cache'):
   apps.cache.get_models.cache_clear()
 if apps.ready:
  COMPLETELY_LOADED = True
 return True

def ensure_completely_loaded ( force = False ) : global COMPLETELY_LOADED if ( COMPLETELY_LOADED and ( not force ) ) : return True from django . apps import apps if ( not apps . ready ) : return import django from distutils . version import LooseVersion if ( LooseVersion ( django . get_version ( ) ) < LooseVersion ( u'1.8' ) ) : for model in apps . get_models ( ) : for cache_name in ( u'_field_cache' , u'_field_name_cache' , u'_m2m_cache' , u'_related_objects_cache' , u'_related_many_to_many_cache' , u'_name_map' ) : try : delattr ( model . _meta , cache_name ) except AttributeError : pass model . _meta . _fill_fields_cache ( ) if hasattr ( apps , u'cache' ) : apps . cache . get_models . cache_clear ( ) if apps . ready : COMPLETELY_LOADED = True return True
this method ensures all models are completely loaded feincms requires django to be completely initialized before proceeding .