def __repr__(self):
    """A custom repr for targetdb models.

    By default it always prints pk, name, and label, if found. Models can
    define they own ``__print_fields__`` as a list of field to be output in the
    repr.

    """

    fields = ['pk={0!r}'.format(self.pk)]

    for ff in self.__print_fields__:
        if hasattr(self, ff):
            fields.append('{0}={1!r}'.format(ff, getattr(self, ff)))

    return '<{0}: {1}>'.format(self.__class__.__name__, ', '.join(fields))