def METHOD_NAME(self, obj):
    """
    Override this to define logic for generating
    the category key from the object instance.
    """
    try:
        return getattr(obj, "category", obj["category"])
    except KeyError:
        # User has registered defaults for a category
        # however category retrieval from object failed
        # Need to fail explicitly and warn the user
        if self._category_defaults:
            raise NotImplementedError(
                "Could not retrieve category information from: {}."
                "You may need to override `get_category`"
                "of the registry.".format(obj)
            )
        raise