@classmethod
def get_field_from_selector(cls, selector):
    """
        Given a django selector, e.g. device__metadata__name, this returns the class
        and the Django field of the model, as returned by Model._meta.get_field().
        Example::

            device__metadata__name -> (SeedDevice, SeeDevice.name)
        """
    if not '__' in selector:
        return cls, cls._meta.get_field(selector)
    model = cls
    while '__' in selector:
        model_name, selector = selector.split('__', 1)
        model = model._meta.get_field(model_name).rel.to
    return model, model._meta.get_field(selector)
