import importlib


def import_serializer_class(location):
    """
    Resolves a dot-notation string to serializer class.
    <app>.<SerializerName> will automatically be interpreted as:
    <app>.serializers.<SerializerName>
    """
    if not isinstance(location, str):
        return location

    pieces = location.split('.')
    class_name = pieces.pop()

    if not pieces:
        raise ValueError('Please ensure class string is fully qualified with its containing module')

    if pieces[ len(pieces)-1 ] != 'serializers':
        pieces.append('serializers')

    module = importlib.import_module( '.'.join(pieces) )
    return getattr(module, class_name)