Exceptionsยค
AlreadyRegistered ยค
Bases: Exception
Raised when you try to register a Component under a name that is already registered with the given ComponentRegistry.
Re-registering the exact same class object under the same name is a no-op and does NOT raise - so calling autodiscover() or import_libraries() more than once is safe. Any other class under that name raises and you must call unregister() first to replace the existing registration.
NotRegistered ยค
Bases: Exception
Raised when you try to access a Component, but it's NOT registered with given ComponentRegistry.
TagProtectedError ยค
Bases: Exception
The way the TagFormatter works is that, based on which start and end tags are used for rendering components, the ComponentRegistry behind the scenes un-/registers the template tags with the associated instance of Django's Library.
In other words, if I have registered a component "table", and I use the shorthand syntax:
Then ComponentRegistry registers the tag table onto the Django's Library instance.
However, that means that if we registered a component "slot", then we would overwrite the {% slot %} tag from django_components.
Thus, this exception is raised when a component is attempted to be registered under a forbidden name, such that it would overwrite one of django_component's own template tags.