def get_entity_pk(serializer):
    """Gets the primary key (PK) of an entity associated with the serializer provided.
    Looks up serializer context for associated view data.

    Parameters:

    - serializer #rest_framework.serializers.BaseSerializer: The serializer instance to use for PK lookup.

    Returns: the PK of the entity if present else #None.
    """
    view_kwargs = serializer.context['view'].kwargs if 'view' in serializer.context else {}
    return view_kwargs.get('pk') if 'pk' in view_kwargs else None