def METHOD_NAME(self, request, pk=None):
    """
    This action will set an attribute if the db_value is defined, or remove
    it if no db_value is provided.
    """
    attr = serializers.AttributeSerializer(data=request.data)
    obj = self.get_object()
    if attr.is_valid(raise_exception=True):
        key = attr.validated_data["db_key"]
        value = attr.validated_data.get("db_value")
        category = attr.validated_data.get("db_category")
        attr_type = attr.validated_data.get("db_attrtype")
        if attr_type == "nick":
            handler = obj.nicks
        else:
            handler = obj.attributes
        if value:
            handler.add(key=key, value=value, category=category)
        else:
            handler.remove(key=key, category=category)
        return Response(
            serializers.AttributeSerializer(obj.db_attributes.all(), many=True).data,
            status=status.HTTP_200_OK,
        )
    return Response(attr.errors, status=status.HTTP_400_BAD_REQUEST)