Skip to content

Exceptions¤

AlreadyRegistered ¤

Bases: Exception

See source code

Raised when you try to register a Component, but it's already registered with given ComponentRegistry.

NotRegistered ¤

Bases: Exception

See source code

Raised when you try to access a Component, but it's NOT registered with given ComponentRegistry.

TagProtectedError ¤

Bases: Exception

See source code

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:

{% table ... %}
{% endtable %}

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.