<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, cache_namespace: str = None, parent_field: str = None) -> type: """ Decorator. Attaches a global key-value store to a Django model. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of the class this is applied to and the ``attribute_name`` of this ``Hierarkey`` object. :param parent_field: Optional. The name of a field of this model that refers to the parent in the hierarchy. This must be a ``ForeignKey`` field. """

        if isinstance(cache_namespace, type):
            raise ImproperlyConfigured('Incorrect decorator usage, you need to use .add() instead of .add')

        def wrapper(model):
            if not issubclass(model, models.Model):
                raise ImproperlyConfigured('Hierarkey.add() can only be invoked on a Django model')

            _cache_namespace = cache_namespace or ('%s_%s' % (model.__name__, self.attribute_name))

            attrs = self._create_attrs(model)
            attrs['object'] = models.ForeignKey(model, related_name='_%s_objects' % self.attribute_name,
                                                on_delete=models.CASCADE)
            model_name = '%s_%sStore' % (model.__name__, self.attribute_name.title())
            kv_model = self._create_model(model_name, attrs)

            setattr(sys.modules[model.__module__], model_name, kv_model)

            hierarkey = self

            def prop(iself):
                from .proxy import HierarkeyProxy

                attrname = '_hierarkey_proxy_{}_{}'.format(_cache_namespace, self.attribute_name)
                cached = getattr(iself, attrname, None)
                if not cached:
                    try:
                        parent = getattr(iself, parent_field) if parent_field else None
                    except models.ObjectDoesNotExist:  # pragma: no cover
                        parent = None

                    if not parent and hierarkey.global_class:
                        parent = hierarkey.global_class()

                    cached = HierarkeyProxy._new(
                        iself,
                        type=kv_model,
                        hierarkey=hierarkey,
                        parent=parent,
                        cache_namespace=_cache_namespace
                    )
                    setattr(iself, attrname, cached)
                return cached


            setattr(model, self.attribute_name, property(prop))

            return model

        return wrapper