def instance_key(model, instance_or_pk):
 return ('%s.%s:%d' % (model._meta.app_label, model._meta.model_name, getattr(instance_or_pk, 'pk', instance_or_pk)))

def instance_key ( model , instance_or_pk ) : return ( '%s.%s:%d' % ( model . _meta . app_label , model . _meta . model_name , getattr ( instance_or_pk , 'pk' , instance_or_pk ) ) )
returns the cache key for this pair .