def get_instance(model, instance_or_pk, timeout=None, using=None):
 primary_key = getattr(instance_or_pk, 'pk', instance_or_pk)
 key = instance_key(model, instance_or_pk)
 data = cache.get(key)
 if (data is not None):
  try:
   instance = model(pk=primary_key, **data)
   instance._state.adding = False
   instance._state.db = (using or DEFAULT_DB_ALIAS)
   return instance
  except:
   cache.delete(key)
 instance = model._default_manager.using(using).get(pk=primary_key)
 data = {}
 for field in instance._meta.fields:
  if field.primary_key:
   continue
  if (field.get_internal_type() == 'FileField'):
   file_value = getattr(instance, field.attname)
   data[field.attname] = file_value.name
  else:
   data[field.attname] = getattr(instance, field.attname)
 if (timeout is None):
  timeout = app_settings.CACHE_TOOLBOX_DEFAULT_TIMEOUT
 cache.set(key, data, timeout)
 return instance

def get_instance ( model , instance_or_pk , timeout = None , using = None ) : primary_key = getattr ( instance_or_pk , 'pk' , instance_or_pk ) key = instance_key ( model , instance_or_pk ) data = cache . get ( key ) if ( data is not None ) : try : instance = model ( pk = primary_key , ** data ) instance . _state . adding = False instance . _state . db = ( using or DEFAULT_DB_ALIAS ) return instance except : cache . delete ( key ) instance = model . _default_manager . using ( using ) . get ( pk = primary_key ) data = { } for field in instance . _meta . fields : if field . primary_key : continue if ( field . get_internal_type ( ) == 'FileField' ) : file_value = getattr ( instance , field . attname ) data [ field . attname ] = file_value . name else : data [ field . attname ] = getattr ( instance , field . attname ) if ( timeout is None ) : timeout = app_settings . CACHE_TOOLBOX_DEFAULT_TIMEOUT cache . set ( key , data , timeout ) return instance
return details on an instance .