'This method is used by the caching subsystem to infer the PK
value from the constructor arguments.  It is used to decide if
an instance has to be built or is already in the cache.'

@classmethod
def _get_cache_key(cls, args, kwargs):

    result = None
    if hasattr(cls._meta, 'pks'):
        pk = cls._meta.pks[0]
    else:
        pk = cls._meta.pk
    pk_position = cls._meta.fields.index(pk)
    if (len(args) > pk_position):
        result = args[pk_position]
    elif (pk.attname in kwargs):
        result = kwargs[pk.attname]
    elif ((pk.name != pk.attname) and (pk.name in kwargs)):
        result = kwargs[pk.name]
    if ((result is not None) and isinstance(result, Model)):
        result = result._get_pk_val()
    return result
